1.使用Jquery實現跳轉
$(location).attr('href',"http://www.google.com"); $jq(window).attr("location","http://www.google.com"); $(location).prop('href',"http://www.google.com");
2.使用JavaScript實現跳轉
// 相當於 HTTP redirect window.location.replace("http://stackoverflow.com"); // 相當於 clicking on a link window.location.href = "http://stackoverflow.com";
JavaScript其它的可實現頁面跳轉的方式
window.history.back(-1); window.navigate("top.jsp"); //old-ie-only self.location = 'top.jsp'; top.location = 'top.jsp'; window.location=window.locaiton.host; winodw.locaiton.assign('http://www.baidu.com'); ducument.location.href='/path'; window.history.go(-1);
3.頁面跳轉路徑錯誤問題
ie8以下的頁面跳轉需要使用絕對路徑,使用相對路徑的時候ie會自動網跳轉的Url上面加上當前頁面的路徑,這會導致跳轉錯誤。 下面是解決辦法:
function Redirect (url) { var ua = navigator.userAgent.toLowerCase(),
原創文章,作者:投稿專員,如若轉載,請註明出處:https://www.506064.com/zh-hant/n/228181.html