09-25-2011, 06:09 PM
I can't figure out why this isn't working.
I'm calling a function from a link in an iFrame, but I want a second function (which builds upon the first) to be called a second after the first one. So I have this:
setTimeout works when it's the only function I'm calling, but it appears that having the two together erases the delayed function.
09-25-2011, 06:39 PM
if parent.func1() redirects to another page, then your code wont work.
09-26-2011, 12:38 AM
Nope, stays on the same page, but both Func1 and Func2 assign new values to the same array, then both call a third function.
09-26-2011, 02:08 AM
This is wrong.
The correct code is
without the quotes/apostrophes.
You *can* code it as
but there's no point. Keep it short and simple.
09-27-2011, 06:58 AM
Thanks, O.P., but it's still not firing. The problem must be with a conflict in the two functions themselves. They're usually not called one after the other unless the first has completely finished already. That's why i thought using setTimeout would work here, but something about the fist function firing just doesn't want the second to work.
09-27-2011, 06:38 PM
Have you tried having the first function call the second function via a setTimeout statement?
09-27-2011, 09:10 PM
just got another thought.. try this out...
Thanks & Regards,
09-29-2011, 11:47 PM
For the life of me, nothing works (and ironboy, I need the two functions to be able to fire independently - though, just to try it, I had the second func fire on a condition inside the first and even that didn't work!). There just must be some irreconcilable conflict between the two.
I've giving up in this for now. It would have been nice to get it to work, but it's not that important, and not that necessary a use of my time.
Thanks for the replies, all. Appreciated as always.
09-30-2011, 12:24 AM
can you post func1 and func2 here aswell? so we can see them?
09-30-2011, 02:43 AM
I think you just have some cockpit error.
A simple test works fine.
**** FILE: junk1.html *****
function func1( )
document.body.style.backgroundColor = "yellow";
function func2( )
document.body.style.color = "green";
document.body.style.fontSize = "xx-large";
<h2>Isn't this fun?<h2>
<h3>Just some random text</h3>
<input type="button" value="Test func1" onclick="func1();"/>
<input type="button" value="Test func2" onclick="func2();"/>
<iframe src="junk2.html" style="width: 100%; height: 200px;"></iframe>
**** FILE: junk2.html *****
<a href="#" onclick="parent.func1(); setTimeout(parent.func2,3000); return false;">
CLICK HERE TO TRY IT
The buttons in junk1.html are just to show what the two functions do.
If you try pushing them, then hit refresh before clicking on the link in the iframe.