Google Answers Logo
View Question
Q: reading URL and using content in page ( Answered,   0 Comments )
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, 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;
var username=URL[URL.length-1];
document.write('Hey '+username+', nice to see you on my page,
unfortunately you mistyped the URL.');
<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.

Request for Answer Clarification by blokje1234-ga on 02 Sep 2005 06:45 PDT

i am using Typo3. do i need to replact your URL by my real url name ?


Clarification of Answer by palitoy-ga on 02 Sep 2005 06:53 PDT
I am not familiar with Typo3 but I believe this is a content management system...

The script should work as I have written it here without any need to
alter anything.  The URL in the script is just a variable name.  You
should just need to paste the javascript into your error page where
you require the greeting to appear.
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy