|
|
Subject:
display html based on referrer javascript
Category: Computers > Algorithms Asked by: questioner1234-ga List Price: $5.00 |
Posted:
13 Jun 2004 10:52 PDT
Expires: 13 Jul 2004 10:52 PDT Question ID: 360419 |
I would like a javascript that will add some html to a page only if the visitor is referred from a search engine. So if they come from yahoo or google, they will see an advertisment that other visitors won't see. I want the ad to be integrated into the page, not a frame or pop-up. | |
| |
|
|
Subject:
Re: display html based on referrer javascript
Answered By: palitoy-ga on 14 Jun 2004 06:57 PDT Rated: |
Hello Questioner1234 This is the script you require: <script language="JavaScript"><!-- if (document.referrer.indexOf('google.com') > -1) document.write('this is where you write out the html to be displayed - remember to escape any quotes!'); else if (document.referrer.indexOf('yahoo.com') > -1) document.write('this is where you write out the html to be displayed for the yahoo visitors'); else document.write('otherwise this gets shown - could be nothing'); //--> </script> As it is shown here it should be placed in between the <head> tags of your document and will write a phrase to the browser should it detect that google.com or yahoo.com was the referrer. Please note that some security settings block this setting. The document.write sections write the code that will display a message or your advert html code. If you have any questions regarding this please ask for clarification and I will do all I can to help. | |
| |
|
questioner1234-ga rated this answer: |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |