I'm having difficulty encountering the contents()
of an IFRAME via jQuery. It is actually a frame within a frame that I'm trying to access. The frames are all from the same source (same domain, same root path, etc.).
I'm currently accessing the frame via:
var $frame = $(window.top.frames[1].document).find('#innerFrameName');
This works fine, and if I console.log
the value of $frame, I see that it's a jQuery array:
[<frame src="mypage.htm" id="innerFrameName" frameborder="1" border="1" scrolling="auto" title="My Inner Frame" name="bsscright">]
However, the moment I try to call the following (as explained in this StackOverflow question), I get an empty array.
var $contents = $frame.contents();
console.log($contents); // => []
Even if I try to get to the document itself, I can't.
var innerDocument = $frame.get(0).document;
console.log(innerDocument); // => undefined
I even tried going about it without jQuery, and I'm getting the same results as above.
var innerFrame = window.top.frames[1].frames['innerFrameName'];
var innerDocument = innerFrame.document;
console.log(innerFrame); // => the DOM object representing the IFRAME
console.log(innerDocument); // => undefined
What am I doing wrong?