1、使用window.location跳转页面
1)使用DOM方式
// 类似做HTTP redirect(重定向)window.location.replace("http://wonhero.com");// 类似点击 linkwindow.location.href = "http://wonhero.com";
2)使用JQuery方式
$(location).attr('href', 'http://wonhero.com')
2、跳转方法redirect兼容IE8及以下
function redirect (url) { var ua = navigator.userAgent.toLowerCase(), isIE = ua.indexOf('msie') !== -1, version = parseInt(ua.substr(4, 2), 10); // Internet Explorer 8 and lower if (isIE && version < 9) { var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } // 所有其他浏览器都可以使用标准的window.location.href window.location.href = url; }}
3、页面重定向可能用到的方法
// window.locationwindow.location.replace('http://www.example.com')window.location.assign('http://www.example.com')window.location.href = 'http://www.example.com'document.location.href = '/path'// window.historywindow.history.back()window.history.go(-1)// window.navigate; 仅支持老版本IEwindow.navigate('top.jsp')// Probably no buenoself.location = 'http://www.example.com';top.location = 'http://www.example.com';// jQuery$(location).attr('href','http://www.example.com')$(window).attr('location','http://www.example.com')$(location).prop('href', 'http://www.example.com')