Click to See Complete Forum and Search --> : alternative to document.referrer
meat-head
12-30-2002, 03:37 AM
i would like call a function upon loading a page (job.html) except when that page is accessed from one specific page (home.html). at first i wrote the condition something like if(document.referrer != "http://blah.com/blah/home.html"). this did not work because home.html referred job.html with window.location = job.html not an anchor tag.
if anyone knows a good way to get job.html to realize what page referred it, i would greatly appreciate your input
BestZest
12-30-2002, 06:00 AM
Don't trust me on this I'm doing it from memory but I think you can use: referer=document.history[-1]
(the 'document.history[-1]' is the important bit, change 'referer' to what you like)
You could then do:
if(referer=="http://www.yoursite.com/home.html"){do-something}
Hope this works,
BestZest
meat-head
12-30-2002, 06:05 AM
thanks, i'll give it a shot
meat-head
12-30-2002, 06:26 AM
hmmmm. it seems the document.history object gives us the back(), forward() and go() methods and the length property but no way of returning the URL of the last page visited. at least from what i could find spending 15 minutes with google. i'm at a loss here. any other suggestions???
Charles
12-30-2002, 07:08 AM
Originally posted by meat-head
hmmmm. it seems the document.history object gives us the back(), forward() and go() methods and the length property but no way of returning the URL of the last page visited. at least from what i could find spending 15 minutes with google. i'm at a loss here. any other suggestions??? Bookmark the page at http://developer.netscape.com/docs/manuals/js/client/jsref/contents.htm and start there when you have a question about JavaScript. You will note that there is no Document.history object or array (http://developer.netscape.com/docs/manuals/js/client/jsref/document.htm) but that there is a Window.history object (http://developer.netscape.com/docs/manuals/js/client/jsref/history.htm#1193137).