我需要使用JavaScript将动态HTML页面重定向到URL。
作为初学者,我需要你的帮助...
我想做的是重定向到网址html页面。
例如:假设页面地址为www.example.com/pages.html?http://yahoo.com/news
,因此在这种情况下,此pages.html
页面会将用户重定向到yahoo.com/news ....我知道如何用PHP做到这一点,但我不明白我应该如何使用JavaScript和HTML。任何的想法?感谢
答案 0 :(得分:2)
这应该这样做:
function Redirect(){
var current = window.location.href;
var exclude = current.indexOf('?');
window.location = current.substr(exclude + 1);
}
setTimeout("Redirect()",5000);
答案 1 :(得分:0)
您可以使用window.location.href="new-url.html";
转到带有JavaScript的网址。
要解析网址,请使用var theURL=window.location.href.split("?")[1];
答案 2 :(得分:0)
location.href = location.href.split("?")[1];