如何使用JavaScript或jQuery重定向到另一个页面?有哪些方式?

如何使用JavaScript或者jQuery重定向到另一个页面?有哪些方式?

不需要使用jQuery进行页面重定向操作,可以使用window.location.replace更好地实现HTTP重定向,replace()比window.location.href更好,因为replace()不会将原始页面保存在历史会话记录中,这样用户点击后退按钮不会无休止地点击失败。如果你需要模拟用户点击一个连接,使用location.href,如果你需要模拟HTTP重定向,使用location.replace,例如:

// HTTP重定向使用location.replace()
function http(){
    window.location.replace("http://www.google.com");
}

// 用户点击使用location.href
function user(){
    window.location.href = "http://www.baidu.com";
}

来源:

https://www.srcmini02.com/960.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_42447.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?