使用jQuery或纯 JavaScript 如何将用户从一页转到另一页?
当前回答
var url = 'asdf.html';
window.location.href = url;
其他回答
如果您想要直接重定向到同一应用程序内的路线, 只需
window.location.pathname = '/examplepath'
这将是前进的道路。
与 jQuery 合作 :
$(window).attr("location", "http://google.fr");
var url = 'asdf.html';
window.location.href = url;
您可以使用以下方法重定向页面:
通过在头部使用元标记 -
<meta http-equiv="refresh" content="0;url=http://your-page-url.com" />
注意:content="0;
... 用于在您需要多少秒后重定向页面使用 JavaScript :
window.location.href = "http://your-page-url.com";
使用 jQuery 查询 :
$(location).attr('href', 'http://yourPage.com/');
在单击功能上,只需添加:
window.location.href = "The URL where you want to redirect";
$('#id').click(function(){
window.location.href = "http://www.google.com";
});