function auth(num) {
var pathName =window.document.location.pathname;
var projectName=pathName.substring(0,pathName.substr(1).indexOf('/')+1);
window.location.href=projectName+"/user/chooseAuthority?auth="+num
}
复制代码
如上代码就能解决问题php
相关知识: 经过js或者html或者PHP等动态程序均可以方便的实现跳转,这里搜集了几种页面跳转的方式 js方式的页面跳转 1.window.location.href方式html
2.window.navigate方式跳转jsp
3.window.loction.replace方式实现页面跳转,注意跟第一种方式的区别spa
有3个jsp页面(1.jsp, 2.jsp, 3.jsp),进系统默认的是1.jsp ,当我进入2.jsp的时候, 2.jsp里面用window.location.replace("3.jsp");与用window.location.href ("3.jsp");从用户界面来看是没有什么区别的,可是当3.jsp页面有一个"返回"按钮,调用window.history.Go(-1); wondow.history.back();方法的时候,一点这个返回按钮就要返回2.jsp页面的话,区别就出来了,当用 window.location.replace("3.jsp");连到3.jsp页面的话,3.jsp页面中的调用 window.history.go(-1);wondow.history.back();方法是很差用的,会返回到1.jsp 。 4.self.location方式实现页面跳转,和下面的top.location有小小区别code
5.top.locationhtm
6.不推荐这种方式跳转string
在php程序中,这种方式跳转前面不能有任何输出it