PDA

View Full Version : SetAttribute Remote Window and Iframe preload


netfervor
06-26-2002, 11:06 PM
I need setAttribute "src" from main windows to pop-up window (Iframe in it) and also i need to prepload all src files ONCE, so if user ever click to open pop-up and do it againt, its no need to loading againt, can anybody help with the script ... ? Or maybe can sugest me with better method to have same result. thanks.

jkd
06-27-2002, 01:58 AM
If you only want to load the document once, I'd suggest looking into XMLHttpRequest, both IE and Gecko have implementations of it, though I'm not sure about loading non-XML docs (XHTML counts as XML remember, with the proper mime-type).

Anyway, say 'newWin' is the variable you assigned the results of window.open() to, I'd imagine something like:

newWin.document.getElementsByTagName('iframe').item(0).setAttribute('src', 'newsrc');

Where the iframe is the first iframe in the new window's document would work - as long as the main window and popup window exist on the same domain. Otherwise you will get some cross-domain scripting errors.

netfervor
06-27-2002, 10:05 PM
BTW i still try to looking without XMLHTTPRequest.
plz let me know if you have something relevan..plz. thankzzz.

jkd
06-28-2002, 12:43 AM
I'm not sure of any way to cache an HTML or XML document reliably without XMLHttpRequest (store it as an object).

I mean, you can preload images by loading them once with new Image(), perhaps if you just change the src once, it also stays in cache?