document.createElement doesn't work across frames (Re: Javascript cross-frame scripting problem)

Martijn Klingens klingens at kde.org
Mon May 2 19:45:01 BST 2005


On Monday 02 May 2005 20:32, Martijn Klingens wrote:
> On Monday 02 May 2005 20:14, Koos Vriezen wrote:
> > Maybe IE timers start ticking after an onLoad or so :-):-)
>
> That might actually not be a bad idea :):)

It doesn't make a difference though, if I add a timeout of a couple of seconds 
I still get the problem.

I did find the real problem cause though: the element is created in another 
document and apparently IE reparents it to the new frame and KHTML does not.

Replace 

    element = document.createElement( "HR" );

with

    element = top.frames['frame2'].document.createElement( 'HR' );

and the testcase works. Can someone confirm that the original code works in IE 
and that the extended version is only needed in KHTML/KJS?

-- 
Martijn




More information about the kfm-devel mailing list