[英]Redirect Using JavaScript
我想從查詢中獲取URL。 (查詢是“?url = urlgoeshere” [其中“ urlgoeshere”是要重定向到的URL])並重定向到該URL。 由於某種原因,當我運行腳本時,它會轉到“ http://mydomain.ext/urlgoeshere ”(其中“ urlgoeshere”是要重定向到的URL)
關於如何解決此問題的任何想法?
這是我當前的代碼:
var loc = window.location.href; var url = window.location.search.split("?url="); var countdown=5 var currentsecond=document.rd.box.value=countdown+1 function redirect(){ if (currentsecond!=1){ currentsecond-=1 document.rd.box.value=currentsecond } else { open(url); return } setTimeout("redirect()",1000) } redirect()
<form name="rd"> <center> <br><br><br><br> <font face="Arial"><b>You will be redirected in<br><br> <input type="text" size="3" name="box"> </form> seconds</b></font> </center>
分割您的網址后。 您的網址將是兩個條目的數組。
url [0]將是您當前的頁面url。
url [1]將是您要重定向的URL。
因此,在您的代碼中使用以下代碼:
open(url[1])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.