views:

216

answers:

1

What is Chrome's equivalent of 'top.document', valid in both FF and IE8.

In Chrome, 'top' is valid, top.length returns 2 (frames)...as it should. But top.document returns 'undefined'. Needed to get an element. top.document.getElementById(id) works perfectly in both FF and IE8.

Thanks in advance, swk

A: 

Have you tried

if (top.document == 'undefined')
{
   top.document = window.top.document || null;
}

Also ive just tested in my chrome browser and top.document returns the actual document so not sure, what version are you using !

RobertPitt
Hey, thanks for that, but no go. Version is 5.0.375.55.'window.top' and 'top' are identical. alert() on both yields 'object DOMWindow'. But its 'document' is 'undefined'.Any other thoughts?-swk
Im currently on the same version so I cant understand how your getting undefined. See: http://a.imagehost.org/0651/to_document.png
RobertPitt
The JS console is giving me: "Unsafe JavaScript attempt to access frame with URL file; Domains, protocols and ports must match"(not a problem with IE8 or FF)Is this giving anyone a clue as where to look next? Thanks... -swk (robert: thanks for hanging in)
Ok so i think this problem is down to Cross Domain Origin, This is a security precaution taken by browsers to stop your site being manipulated with things such as cookies etc i believe. Somehow you have to tell the frames that they can be access by the parent frame. Here is an article regrading this issue. http://softwareas.com/cross-domain-communication-with-iframes Also try look googel for "Iframes and ajvascript" "Iframes security with cross domain". Also google use a method of making this work with the HTTP-Headers but im not fully sure about that. Im sure this is the problem tho. Regards
RobertPitt
So, as I understand that article, the idea is to set the 'top' URL via, “parent.frames[1].location.href=correctURL", after which 'top.document' should then be be able to yield its elements.Hmm. Let me give it a shot, and I'll get back. Thanks, -sk
No dice. The browser goes to an all white screen, and locks up.
Is there other way you can do this without using frames, I also noticed that your awaiting responses on the Google chrome deb team, any response from them yet ?
RobertPitt
I wouldn't necessarily mind adopting the scrolling <div> method, and i might yet go that route, but this is really a shortcoming in Chrome. IE8, FF, Safari and Opera pose no difficulty. Here's what I'm doing successfully in those four:frm= top.document.getElementById("frmset"); if ( firefox() ) // etc. { frm.rows= "24.0%, *" ;}
No, nothing yet from the Chrome people. Thanks for hanging in.