I have a document set up like this.
┌root
│
├──iframe
│ │
│ └──scripta
│
└──scriptb
Inside scripta, x is set to some value.
How do I access this value within scriptb, as soon as it's available? Preferably, give your example as printing it within root. I tried just setting a do nothing while loop that terminated when it was set, but that makes the browser hang. (For longer than it should?)
None.
Hmm... seems like you just need a different way of thinking this out. What happens when x is set? Can you just provide the real problem?
None.
I've never heard of a way of accessing variables from a page within an iframe, I think browsers simply load it as a completely different page, and if you could modify it you'd be able to modify other pages in the browser.
None.
I tried just setting a do nothing while loop that terminated when it was set, but that makes the browser hang.
I assume here that he has absolutely no problem accessing it, just his method sucks and he's hoping for something that doesn't hang. I mean, if it wasn't even a possibility to share javascript values between frames, you could write the variable to the iframe html and then access that to share it with the parent javascript.
None.
This is the real problem, IP.
It's literally all I'm doing - I'm trying to get better at JS.
I can access it perfectly fine once I cause an event and the page has finished loading, the problem is I want determine exactly when it's set, and then output it in the parent document.
<iframe src='page2' id='frame'></iframe>
<script>
document.write(window.frame.x);
</script>
<script>
var x;
x = 'test';
</script>
Obviously I shouldn't be using document.write, but innerHTML(whatever) = window.frame.x, but whatever. I just need to know how to check when window.frame.x is set.
Post has been edited 1 time(s), last time on Nov 22 2009, 12:48 am by Syphon.
None.
That code works (tested in Chrome, FireFox 3.5, and IE8), you just need to wait for the 2nd page to load.
<iframe src='page2.htm' id='frame'></iframe><br />
<input type='button' value='Get x' onclick='alert(window.frame.x);' />
TinyMap2 - Latest in map compression! ( 7/09/14 - New build! )
EUD Action Enabler - Lightweight EUD/EPD support! (ChaosLauncher/MPQDraft support!)
EUDDB -
topic - Help out by adding your EUDs! Or Submit reference files in the References tab!
MapSketch - New image->map generator!
EUDTrig -
topic - Quickly and easily convert offsets to EUDs! (extended players supported)
SC2 Map Texture Mask Importer/Exporter - Edit texture placement in an image editor!
This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!
Why not, then, just call a function when x is changed, passing it to a parent function? Obviously x is set because the function is called.
None.
I ended up just using setTimeout() and setInterval()... Works well enough but I guess server lag will break a bit if I set it to check too often.
None.