access to contents of iframe via dom

VERIFIED INVALID

Status

()

Core
DOM
P3
normal
VERIFIED INVALID
18 years ago
17 years ago

People

(Reporter: rvj, Assigned: jst)

Tracking

Trunk
Other
Other
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

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

(Reporter)

Description

18 years ago
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>
(Reporter)

Comment 1

18 years ago
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


Updated

18 years ago
QA Contact: gerardok → ckritzer
(Reporter)

Comment 2

18 years ago
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?

Comment 3

18 years ago
this old bug wants attention. reassigning to jst for triage
Assignee: vidur → jst

Updated

18 years ago
Status: UNCONFIRMED → NEW
Ever confirmed: true

Comment 4

18 years ago
nominating for nsbeta2 based on:
 - visibility
 - feature (DOM Level 1 Standards Compliance) broken
Keywords: nsbeta2
(Assignee)

Comment 5

18 years ago
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

Comment 6

18 years ago
Putting on nsbeta2- radar.  But ckritzer, could you please retest?
Whiteboard: [nsbeta2-]

Comment 7

18 years ago
rvj@rolemodels.net, could you re-test this?  Thanks! -ckritzer
Whiteboard: [nsbeta2-] → [nsbeta2-] - requested info from Reporter
(Assignee)

Comment 8

18 years ago
Since noone has confirmed that this is really broken I'm moving this forward to
M17, someone please test this.
Target Milestone: --- → M17
(Assignee)

Comment 9

18 years ago
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
Last Resolved: 18 years ago
Resolution: --- → INVALID

Comment 10

18 years ago
Mass update of qa contact
QA Contact: ckritzer → janc

Comment 11

17 years ago
verified
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.