"Frame" <> schreef in bericht
news:...
> I'm looking for tutorials or articles considering HTML Frames and how to
> handle them with Javascript.
>
> E.g. samples how Frames can exchange information, can a Frame instruct
> other Frame to update it's content etc.
>
> This kind of information is welcome.
>
> Cheers!
>
>
>
Hi, I made a function for this that loops over all frames in the current
window and tries to execute specific code on these frames.
So when function is called it tries to execute it on all frames it can find,
if function doesn't exist, it will do nothing.
(it works on firefox and iexplore). Well I use it quite often because it is
just one line of code and everything goes cross frame. There are some
drawbacks, one of them is you must yourself manage the executable codes in
the frames to avoid unwanted execution.
you could for example call: firecode('alert(\"I am a frame\");');
And every frame shows an alert.
or firecode('changecolor();');
and every frame that has changecolor() in it will execute it. What
changecolor is is up to you

Just make a function changecolor that changes the background of some frame,
and call above code.
here is the function:
function firecode(code)
{
framestruct(window, 1, code);
}
function framestruct(el, start, func)
{
var m = 20;
if(!start)
{
if((navigator && navigator.userAgent && navigator.userAgent.indexOf &&
navigator.userAgent.indexOf('Gecko') != -1) ||
(navigator.userAgent.indexOf("Netscape")!= -1))
{
try
{
el.eval("try{" + func + "}catch(e){}");
}
catch(e)
{}
}
else
{
try{el.execScript("try{" + func + "}catch(e){}");}catch(e){};
}
}
else
{
for(;m>=0&&el.parent;m--)
{
el = el.parent;
}
}
var f = el.frames;
var i;
for(i=0; i<f.length; i++)
{
framestruct(f[i], 0, func);
}
}
greetz Bert