Erik Beeson wrote:
To get elements by tag name in jQuery, do $('tagName')

Also, I suggest you do "feature detection" instead of "browser
detection", as described here:
http://www.quirksmode.org/js/support.html

What I mean is, try something like this:

var frame = $('iframe')[0];
var frameDocument;
if(frame.contentDocument && frame.contentDocument.documentElement) {
  frameDocument = frame.contentDocument.documentElement;
} else if(document.frames[0] && document.frames[0].document) {
  frameDocument = document.frames[0].document;
} ...


A little shorter and also instead of relying on a hardcoded frames[0] reference, using the already existing reference through the frame variable:

var frameDocument = frame.contentWindow && frame.contentWindow.document || frame.contentDocument.documentElement;

frame.contentWindow is IE specific, all other major browsers support frame.contentDocument, thus I use this as fallback...


--Klaus

Reply via email to