Staredit Network > Forums > Technology & Computers > Topic: Help me out, I'm Javascripture Illiterate
Help me out, I'm Javascripture Illiterate
Nov 21 2009, 10:20 am
By: Syphon  

Nov 21 2009, 10:20 am Syphon Post #1



I have a document set up like this.

Code
┌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.

Nov 21 2009, 1:37 pm Forsaken Archer Post #2



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.

Nov 21 2009, 2:47 pm Falkoner Post #3



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.

Nov 21 2009, 5:35 pm Forsaken Archer Post #4



Quote
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.

Nov 22 2009, 12:40 am Syphon Post #5



This is the real problem, IP. :P

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.

Code
<iframe src='page2' id='frame'></iframe>

<script>
document.write(window.frame.x);
</script>


Code
<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.

Nov 22 2009, 4:36 am O)FaRTy1billion[MM] Post #6

👻 👾 👽 💪

That code works (tested in Chrome, FireFox 3.5, and IE8), you just need to wait for the 2nd page to load.
Code
<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!
\:farty\: This page has been viewed [img]http://farty1billion.dyndns.org/Clicky.php?img.gif[/img] times!

Nov 22 2009, 8:10 am Forsaken Archer Post #7



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.

Nov 22 2009, 12:58 pm Syphon Post #8



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.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[2026-4-26. : 1:58 pm]
lil-Inferno -- ya
[2026-4-25. : 11:50 pm]
JamaL -- Glad to see SEN will never die. Kudos to whoever is paying the hosting fees these days!
[2026-4-25. : 3:37 pm]
NudeRaider -- (-.-,)
[2026-4-25. : 3:35 pm]
Zoan -- ;o I thought that was a monkey emote
[2026-4-25. : 3:34 pm]
Zoan -- :mods:
[2026-4-25. : 3:34 pm]
Zoan -- :mods"
[2026-4-25. : 3:20 pm]
NudeRaider -- Vrael
Vrael shouted: moderation? on SEN? in 2026? completely localized in anoeth47's topic? at this time of year?
boy, if you're not careful I'll moderate your sorry ass too!
[2026-4-25. : 3:06 pm]
RIVE -- Yyyes. Don't you see it?
[2026-4-25. : 2:11 pm]
Vrael -- moderation? on SEN? in 2026? completely localized in anoeth47's topic? at this time of year?
[2026-4-25. : 1:39 pm]
NudeRaider -- anoeth47
anoeth47 shouted: Can I get a moderator/lord of the forum to clean up my topics - delete posts not really part of the topic.
send me the links of the posts you want deleted via pm
Please log in to shout.


Members Online: DarkenedFantasies