如何用js实现页面跳转

 

利用window.loaction的属性实现界面跳转,这个可以用在ajax的回调函数中

var path = window.location.pathname;

var slashIndex = path.indexOf("/", 1); //用来取得项目名

var context = window.location.protocol + "//" + window.location.host + path.substring(0,slashIndex+1) + "pages/index.html"

window.location.href=context; //实现跳转

posted on 2016-04-08 16:24  windrainer  阅读(447)  评论(0)    收藏  举报

导航