Closed Bug 29202 Opened 25 years ago Closed 24 years ago

access to contents of iframe via dom

Categories

(Core :: DOM: Core & HTML, defect, P3)

Other
Other
defect

Tracking

()

VERIFIED INVALID

People

(Reporter: rvj, Assigned: jst)

Details

(Whiteboard: [nsbeta2-] - requested info from Reporter)

I believe from the DOM newsgroup that access to the contents of an iframe has 
not been implemented?

The syntax below always returns 0 elements using
 tags = window.document.frames('sid').getElementsByTagName('H2');
  
I have also tried
tags = window.document.frames('sid').document.getElementsByTagName('H2');

I probably have the syntax wrong anyway since it bares no relation to the 
current IE5 syntax.


<HTML>
<HEAD>

<SCRIPT>
function test()
{
 alert("count H2 tags");
 tags = window.document.frames('sid').getElementsByTagName('H2');
 alert("H2 tags"+tags.length);
}
</SCRIPT>
<BODY onclick="test()">
<DIV >
<IFRAME  ID="sid"  SRC='source.htm'></IFRAME>
</DIV>
</BODY>

</HEAD>
</HTML>
sorry   the initial description should have referred to

tags = document.getElementById('sid').getElementsByTagName('h2');

and

tags = document.getElementById('sid').document.getElementsByTagName('h2');

I copied the script from the 'IE5' syntax


QA Contact: gerardok → ckritzer
Access to the contents of iframe using DOM is essential for script based 
processing. Isnt DOM access to a frame/iframe document property via 
getElementById a DOM1 feature?
this old bug wants attention. reassigning to jst for triage
Assignee: vidur → jst
Status: UNCONFIRMED → NEW
Ever confirmed: true
nominating for nsbeta2 based on:
 - visibility
 - feature (DOM Level 1 Standards Compliance) broken
Keywords: nsbeta2
DOM Level 2 defines a contentDocument on frame and iframe elements and that's
even implemented in mozilla, IMO this is fixed but could someone test it, and
mark this fixed if it works?
Status: NEW → ASSIGNED
Putting on nsbeta2- radar.  But ckritzer, could you please retest?
Whiteboard: [nsbeta2-]
rvj@rolemodels.net, could you re-test this?  Thanks! -ckritzer
Whiteboard: [nsbeta2-] → [nsbeta2-] - requested info from Reporter
Since noone has confirmed that this is really broken I'm moving this forward to
M17, someone please test this.
Target Milestone: --- → M17
Well, this turns out to be a invalid bug,

  tags = document.getElementById('sid').getElementsByTagName('h2');

is invalid because it only searches for the "h2" elements within the same
document, it never goes out to the document in the iframe. And

  tags = document.getElementById('sid').document.getElementsByTagName('h2');

is invalid bacause document.getElementById('sid') returns a iframe *element*,
and there's no document property on iframe elements, but there is a
contentDocument property and that works. Either one of the following lines of
code works:

 tags = 
   document.getElementById('sid').contentDocument.getElementsByTagName('h2');

 tags = window.frames['sid'].document.getElementsByTagName('h2');

The former one is fully DOM Level 2 compliant.

Marking this bug invalid.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → INVALID
Mass update of qa contact
QA Contact: ckritzer → janc
verified
Status: RESOLVED → VERIFIED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.