View Full Version : getting document.URL to change immediately

06-16-2004, 01:29 PM

I have a select box which onChange calls a function which sets the current URL using document.URL. Within that function I want to refer to a div in the new document but the div doesn't appear to exist even though I know it does. I also want to call javascript functions which belong to the new document but don't exist in the calling document.If I do

function getNewDocument(){
document.URL = "http://myserver/index.cfm";
alert(document.URL) ;

the 1st alert returns the URL of the document which contains the select box. the 2nd alert returns null, because there is no "top" in the original document.
How can I make document.URL take effect immediately?


06-17-2004, 07:03 AM
It doesn't exist because the new page has not yet loaded. But even if the new page loads, the previous page including the script is already gone.

What do you really want to achieve with this?