Helpful Information
 
 
Category: DOM and JSON scripting
SetAttribute Remote Window and Iframe preload

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.

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.

BTW i still try to looking without XMLHTTPRequest.
plz let me know if you have something relevan..plz. thankzzz.

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?










privacy (GDPR)