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.
[06:24 pm]
NudeRaider -- "War nie wirklich weg" 🎵
[03:33 pm]
O)FaRTy1billion[MM] -- o sen is back
[01:53 am]
Ultraviolet -- :lol:
[2024-4-26. : 6:51 pm]
Vrael -- It is, and I could definitely use a company with a commitment to flexibility, quality, and customer satisfaction to provide effective solutions to dampness and humidity in my urban environment.
[2024-4-26. : 6:50 pm]
NudeRaider -- Vrael
Vrael shouted: Idk, I was looking more for a dehumidifer company which maybe stands out as a beacon of relief amidst damp and unpredictable climates of bustling metropolises. Not sure Amazon qualifies
sounds like moisture control is often a pressing concern in your city
[2024-4-26. : 6:50 pm]
Vrael -- Maybe here on the StarEdit Network I could look through the Forums for some Introductions to people who care about the Topics of Dehumidifiers and Carpet Cleaning?
[2024-4-26. : 6:49 pm]
Vrael -- Perhaps even here I on the StarEdit Network I could look for some Introductions.
[2024-4-26. : 6:48 pm]
Vrael -- On this Topic, I could definitely use some Introductions.
[2024-4-26. : 6:48 pm]
Vrael -- Perhaps that utilizes cutting-edge technology and eco-friendly cleaning products?
[2024-4-26. : 6:47 pm]
Vrael -- Do you know anyone with a deep understanding of the unique characteristics of your carpets, ensuring they receive the specialized care they deserve?
Please log in to shout.


Members Online: Ultraviolet