最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

Javascript: document.referrer - Stack Overflow

matteradmin8PV0评论

Say I have included document.referrer() in my website(www.abc) and I got redirected to my site from google.

Will the above mentioned code help me to get google?

Say I have included document.referrer() in my website(www.abc.) and I got redirected to my site from google..

Will the above mentioned code help me to get google.?

Share Improve this question edited May 5, 2011 at 6:51 kapa 78.8k21 gold badges165 silver badges178 bronze badges asked May 5, 2011 at 6:44 jagrtijagrti 551 gold badge1 silver badge2 bronze badges 2
  • 1 cant try bcoz i dont have any site. .:-( – jagrti Commented May 5, 2011 at 6:47
  • 1 try using jsfiddle, you can try out any script you need. Or you rcould even try it yourself on w3schools on there interactive tutorial w3schools./jsref/prop_doc_referrer.asp and w3schools./jsref/tryit.asp?filename=tryjsref_doc_referrer – Tom Gruner Commented May 5, 2011 at 7:01
Add a ment  | 

2 Answers 2

Reset to default 1

The search results in Google are not direct links. For example searching for abc the first result actual link is: http://www.google.co.uk/url?sa=t&source=web&cd=1&ved=0CC0QFjAA&url=http%3A%2F%2Fabc.go.%2F&ei=_0nCTeOMFYOVswbY7PyHAQ&usg=AFQjCNHN69w2aXwjgMlF4X6o9W3lKd4uZw

The redirection is then made server side so the code in abc.go. website might not get proper referrer.

javascript:alert(document.referrer);

When you will insert it at address bar, the previous location will appear, like the addresses appear on address bar, like http://php/manual/en/control-structures.break.php. You can use it to make plex JavaScript operations, like regular expressions. I will give very simple example

<script type="text/javascript">
if (document.referrer.search('google')==-1){
    alert('Not using Google');
} else {
    alert('Yes, from Google');
}
</script>

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far