Ok, so I have this code:
[code]
function check(tab) {
var src = $('editor').src;
if (src.substring(0,31) != "<my
site.com>")
{
alert("access violation");
removeElement(tab);
focusTab('ide_tab0', 'start.php');
return false;
}
else
{
setTimeout(check(tab), 1000);
return true;
}
}
[/code]
But this makes an infinite loop, and the function eventually fails due
to recursion errors. Is there any way to have this run in the
background? So other code can run while it is waiting for execution? I
have it setup with connect('editor','onload',check(tab)), so the DOM
should load before it runs, and there should be no errors, it just
needs to be able to load the rest of the page while the loop is
running.
Any thoughts?
Thanks
On Nov 16, 2:25 pm, Jon Butler <
jonbutle...@googlemail.com> wrote:
> Yeah, that was my original thinking, but onload doesnt fire when I
> change the src.
>
> I tried using a loop before, but I thought it would be more efficient
> to use a custom event. Thiinking about it, the listener would still
> need to check when the src changes so it's pretty much the same
> solution.
>
> Il have another go and post back if I run into problems.
>
> Cheers
>
> On 16 Nov 2008, at 10:06, "Yoann Aubineau" <
yoann.aubin...@gmail.com>
> wrote:
>
> >> Yeah, turns out onchange doesnt detect the change in src....
>
> > Maybe "onload" will do. I never use iframes so I can't say for sure it
> > will work on every browser. But it sounds like a logical try to me.
>
> > If the iframe's source changes on a link or button click, you can also
> > listen for those events, check if the iframe's source is actually
> > different from the previous value and then fire the custom event you
> > need.
>
> > Otherwise, setup a loop that check regulary iframe.src but … eark !
>
> > -- Yoann
>
> > 2008/11/16 jonbutler88 <
jonbutle...@googlemail.com>: