你怎麼能做出一個簡單的JavaScript重定向腳本(不需要jQuery)從一個網頁重定向到另一個?如何使用JavaScript製作重定向頁面?
header('Location:http://www.myredirectwebpage.com/');
但用javascript?
你怎麼能做出一個簡單的JavaScript重定向腳本(不需要jQuery)從一個網頁重定向到另一個?如何使用JavaScript製作重定向頁面?
header('Location:http://www.myredirectwebpage.com/');
但用javascript?
這是一個簡單的重定向網頁的方法,不需要jquery!
<html>
<head>
<script>
function redirect() {
window.location.assign("http://www.mywebsiteurl.com")
}
</script>
</head>
<body>
<input type="button" value="clik here ... redirect" onclick="redirect()">
</body>
</html>
<script>
window.location.href = 'http://www.myredirectwebpage.com/';
</script>
雖然此代碼片段可能解決問題,[包括解釋] (http://meta.stackexchange.com/questions/114762/explaining-entirely-code-based-answers)確實有助於提高質量你的帖子的可靠性。請記住,您將來會爲讀者回答問題,而這些人可能不知道您的代碼建議的原因。 –
下面是一個簡單的方法來從網頁1重定向到webpage2
<input type='button' onclick='Redirect()' value='Redirect To WebPage2' />
<script type='text/javascript'>
function Redirect()
{
window.location = 'http://www.webpage2.com';
//-- You can also use window.location.href = 'http://www.webpage2.com';
}
</script>
'window.location.href =的 'http:// www.myredirectwebpage.com /'' –
可能重複[如何使用Javascript重定向?](http://stackoverflow.com/questions/4744751/how-do-i-redirect-with-javascript) – Marcus