PDA

View Full Version : get the end of new page load


sam
02-12-2003, 07:42 PM
Hi!
Let me try to make that clear:
I use JS to open a new page, and since I use a var to do that (var newPage= window.open(...)) I therefore can refer to that new page from the original page.
Now starts the problem: what I'm tyring to do is to change the source of an image (Note: I can't use ASP) that is already on the page based on the users selection. However, when I put in the line of code (i.e.: newPage.image1.src="...") I get a message pop-up saying "image1 is undefined" and other such messages.
Is there a way of either 1) waiting for the object (Image) to load, or 2) sending the new image source to a script in the new page?
I have read somewhere about a property called "readystate" but it didn't say very clearly how to use it, or if was even what I am looking for.

Sam.

requestcode
02-12-2003, 08:14 PM
You might try newPage.document.image1.src="..."

sam
02-13-2003, 01:57 PM
Thanks, but that doesn't help. :(
The problem seems to be that it can't find the object (image) because it hasn't loaded yet.
To further clarify: When I try this script in IExplorer, but not on the web, i.e. by just opening the page straight from my computer, then script works fine and the image is how I want it. However, when I try the exact same thing on the web (actually, I'm using IIS on my computer, but I understand it's the same thing as the web itself) I get the error message.
So now I'm even more stuck.

Sam.

P.S. Would you know if "window.opener" would work, and if yes, how would I use it?

king443
02-13-2003, 03:10 PM
Can you not pass the image name as an argument to the open call? something like this...


window.open("new.html?myImage=image1.jpg");


in the new.html use the location object to get the arguments and use them.

hope this helps

sam
02-13-2003, 07:28 PM
King, I wasnt aware that I could use that, and I'm not even sure how to fully implement it. Thanks anyway.
However :thumbsup: , I found another solution to the problem. Basicly I use "document.write" to write a complete new page and use varibles and arguments to fill in the required bits. On the one hand I save having to creat an extra page, but on the other hand, and I havn't checked it out yet, I think it might take longer to load, espacially with a Dial-Up connection.
But yeah, I'm gona use anyway.
Thanks you all.

Sam.