?
Solved

How to get previous URL in IE?

Posted on 2001-07-01
23
Medium Priority
?
15,583 Views
Last Modified: 2012-06-22
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.



0
Comment
Question by:kennon2000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 5
  • 3
  • +4
23 Comments
 
LVL 1

Expert Comment

by:jmulder
ID: 6242108
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242141
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242143
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
document.write(history.toString())
netscape.security.PrivilegeManager.disablePrivilege("UniversalBrowserRead");


Michel
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
LVL 12

Expert Comment

by:ahosang
ID: 6242149
These are not supported in IE, and even in Netscape need signed scripts.
0
 
LVL 12

Expert Comment

by:ahosang
ID: 6242152
Sorry to repeat what you said Michel, your comment was not there when I posted :-)
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242174
LOL

Michel
0
 
LVL 1

Expert Comment

by:jmulder
ID: 6242196
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242198
LOL - does it say it is supported by IE4 - and then has
netscape.security.PrivilegeManager ???
Hmmm

Michel
0
 
LVL 1

Expert Comment

by:jmulder
ID: 6242309
>> 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
 
LVL 2

Expert Comment

by:serg111
ID: 6243458
Actually you can get previous page under document.referrer
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6243826
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
 
LVL 1

Expert Comment

by:rxolotl
ID: 6244899
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6244963
Huh?

Michel
0
 

Author Comment

by:kennon2000
ID: 6245571
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
 
LVL 1

Expert Comment

by:jmulder
ID: 6247640
>> 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
 
LVL 7

Expert Comment

by:cstsang
ID: 6267503
Try this one!
<script language=javascript>
   alert("The previous page URL is "+document.referrer);
</script>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6268259
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
 
LVL 1

Expert Comment

by:jmulder
ID: 6270491
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
 

Author Comment

by:kennon2000
ID: 6272255
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
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6273047
If the document.referrer works for you, that is the one to use.

Michel
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 320 total points
ID: 6273051
Otherwise you are out of luck unless the page you visited is on your site and you can set a cookie

Michel
0
 

Author Comment

by:kennon2000
ID: 6275938
Although it is not exactly what I want, Michel gave me a possible approval.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6276142
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses how to implement server side field validation and display customized error messages to the client.
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question