How to get previous URL in IE?

Dear All,

Does anybody know how to obtain the URL of the previous page visited under IE?
I find that many window.history properties as below only support Netscape.

window.history.current
window.history.previous
window.history.next

So how?  It should be simple!  But cannot find solution in my 2-inch-thick Javascript reference.  Please help.



kennon2000Asked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
Otherwise you are out of luck unless the page you visited is on your site and you can set a cookie

Michel
0
 
jmulderCommented:
window.history.current
window.history.previous
window.history.next

Are all suported from NS3 and IE4 onwards.

You can use...

prevURL = window.history.previous;

document.write( "The previous history string is: " + prevURL);
0
 
Michel PlungjanIT ExpertCommented:
Huh - jmulder, how do you get that info???

Only NETSCAPE and ONLY with a signed script using UniversalBrowserRead access may look at the history.

You can look at document.referrer if is is set, but that is only the case if the previous page was a web page too - so not bookmarks or url typed in or dropped

Michel
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Michel PlungjanIT ExpertCommented:
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
document.write(history.toString())
netscape.security.PrivilegeManager.disablePrivilege("UniversalBrowserRead");


Michel
0
 
ahosangFinance Systems DeveloperCommented:
These are not supported in IE, and even in Netscape need signed scripts.
0
 
ahosangFinance Systems DeveloperCommented:
Sorry to repeat what you said Michel, your comment was not there when I posted :-)
0
 
Michel PlungjanIT ExpertCommented:
LOL

Michel
0
 
jmulderCommented:
Oops!

I forgot to add the line:

netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");

at the top of the example.

I got it from my Sams manual: Pure JavaScript by Wyke, Gilliam and Ting. pg 748.

Funny...this book is usually quite accurate :(

Didn't mean to cause an avalanche of disgust.
0
 
Michel PlungjanIT ExpertCommented:
LOL - does it say it is supported by IE4 - and then has
netscape.security.PrivilegeManager ???
Hmmm

Michel
0
 
jmulderCommented:
>> does it say it is supported by IE4

Yep. JavaScript1.1+, ECMASCript1.0+, JScript3.0+, Nav3+, IE4+

And in the appendix in the list for IE-supported syntax is: history.next, history.previous, history.current

The example given has a note which reads:
"In Navigator 4 and later, getting the next value requires the UniversalBrowserRead privilege."
0
 
serg111Commented:
Actually you can get previous page under document.referrer
0
 
Michel PlungjanIT ExpertCommented:
As I already said:
"You can look at document.referrer if is is set, but that is only the case if the previous page was a web page too - so not bookmarks or url typed in or dropped"

Michel
0
 
rxolotlCommented:
0
 
Michel PlungjanIT ExpertCommented:
Huh?

Michel
0
 
kennon2000Author Commented:
imulder, I am the one who ask this question.  I actually use exactly the same reference book to you.  But when u used these properties become "undefined" in IE.  Then I found in a web stating that those properties work only in Netscape.
Now the question become: if I use document.referrer, I still cannot get the previous URL, what should I do?

Can I do it by VBScript or JScript instead?  I accept these two languages even though they may not work in Netscape.

0
 
jmulderCommented:
>> You can check this link
>> http://www.webreference.com/dhtml/column34/4.html

A very interesting article about "Speeding Up Frame Rates For DHTML Animation in Win98" :-?

kennon2000
As you can see from my posts...I have no experiance using this call...I just looked it up for you...the others seem to have more info.

>> I actually use exactly the same reference book to you.

It's usually a very good book.
0
 
KNVB HKSITOCommented:
Try this one!
<script language=javascript>
   alert("The previous page URL is "+document.referrer);
</script>
0
 
Michel PlungjanIT ExpertCommented:
Come on  cstsang  - you have been a member long enough not to answer a question that has many comments - TWO of which are using what you suggest!!!

Kennon: Please reject cstsang's answer

Thanks

Michel
0
 
jmulderCommented:
I only ever post comments since I believe there is always the possibility (and sometimes probability) that someone can give a better solution.

So, is it possible to remove an answer (or change it to a comment) if it where accidently posted as such?
0
 
kennon2000Author Commented:
Of course I will reject cstsang's answer as it is actually not proposed by him.
But...could anyone can give me any possible suggestion to solve this problem? It is very different between getting a previous document and getting the previous URL.

Kennon2000
0
 
Michel PlungjanIT ExpertCommented:
If the document.referrer works for you, that is the one to use.

Michel
0
 
kennon2000Author Commented:
Although it is not exactly what I want, Michel gave me a possible approval.
0
 
Michel PlungjanIT ExpertCommented:
Sorry I could not be of more service...

If you are desparate and the user allows you, you might use wsh to read the MRU list (most recently used) off the registry, but I guess you are not THAT desparate ;-)

Michel
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.