kennon2000
asked on
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.
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.
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
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
netscape.security.Privileg eManager.e nablePrivi lege("Univ ersalBrows erRead");
document.write(history.toS tring())
netscape.security.Privileg eManager.d isablePriv ilege("Uni versalBrow serRead");
Michel
document.write(history.toS
netscape.security.Privileg
Michel
These are not supported in IE, and even in Netscape need signed scripts.
Sorry to repeat what you said Michel, your comment was not there when I posted :-)
LOL
Michel
Michel
Oops!
I forgot to add the line:
netscape.security.Privileg eManager.e nablePrivi lege("Univ ersalBrows erRead");
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.
I forgot to add the line:
netscape.security.Privileg
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.
LOL - does it say it is supported by IE4 - and then has
netscape.security.Privileg eManager ???
Hmmm
Michel
netscape.security.Privileg
Hmmm
Michel
>> 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."
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."
Actually you can get previous page under document.referrer
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
"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
You can check this link
http://www.webreference.com/dhtml/column34/4.html
http://www.webreference.com/dhtml/column34/4.html
Huh?
Michel
Michel
ASKER
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.
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.
>> 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.
>> 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.
Try this one!
<script language=javascript>
alert("The previous page URL is "+document.referrer);
</script>
<script language=javascript>
alert("The previous page URL is "+document.referrer);
</script>
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
Kennon: Please reject cstsang's answer
Thanks
Michel
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?
So, is it possible to remove an answer (or change it to a comment) if it where accidently posted as such?
ASKER
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
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
If the document.referrer works for you, that is the one to use.
Michel
Michel
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Although it is not exactly what I want, Michel gave me a possible approval.
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
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
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);