|
|
Subject:
reading URL and using content in page
Category: Computers > Algorithms Asked by: blokje1234-ga List Price: $10.00 |
Posted:
02 Sep 2005 00:57 PDT
Expires: 02 Oct 2005 00:57 PDT Question ID: 563417 |
i need a script / html / ? which makes it possible to read the typed URL, and use (pieces) of the content in a webpage. For example when somebody types www.mywebsite.com/blokje1234-ga, it normally goes to the errorpage. I want to edit this errorpage in a matter that it says: ' hey blokje1234-ga, nice to see you on my page, unfortunately you mistyped the URL'. please advise |
|
Subject:
Re: reading URL and using content in page
Answered By: palitoy-ga on 02 Sep 2005 01:57 PDT |
Hello blokje1234-ga Thank-you for your question. The easiest way to achieve this is by a little javascript. Simply place the following code on your error page where you want the greeting to be. <script type="text/JavaScript"> var URL=document.referrer; URL=URL.split("/"); var username=URL[URL.length-1]; document.write('Hey '+username+', nice to see you on my page, unfortunately you mistyped the URL.'); </script> <noscript>Hey you, nice to see you on my page, unfortunately you mistyped the URL.</noscript> Description of the script: The script takes the URL of the referring document and splits it into parts where there is a / character. The username is the last part of the URL so we define this to a variable. The string is then printed out on the screen. If the user does not have javascript enabled in their browser it outputs the string enclosed within the <noscript></noscript> tags (a generic message). If you need any further help on this subject please ask for clarification. The script may need a little tweaking depending on the server your site is being hosted on, so if you require any further clarification please include either your URL (so I can determine the server) or let me know the server type yourself. | |
| |
|
|
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 |