2011-07-13 143 views
0

比如我目前的網址是如何獲得母公司網址

http://www.sample.com/check/?code=1 

網頁下此URL包含一個鏈接

<a href="http://www.sample.com/check/?code=2">Code2</a> 

當這個鏈接被點擊才能http://www.sample.com/check/?code=2

問題:http://www.sample.com/check/?code=2下顯示的網頁下,我必須獲取此pa的url ge從此而來。這個怎麼做。

在此先感謝...

回答

3
<script type="text/javascript"> 
alert(document.referrer); 
</script> 
1

如果你控制了原來的頁面,那麼你可以把源的URL是這樣的:

<a href="http://www.sample.com/check/?code=2&scr=http://foo.com/xxxx">Code2</a> 

,你可以從第二頁的URL中解析出來。

或者你可以在第二頁看document.referrer,看看它是否包含你想要的值。有關推薦人的信息,請參閱https://developer.mozilla.org/en/document.referrer