Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9550 (closed defect: duplicate)

Opened 2 years ago

Last modified 1 year ago

Element.getElementsBySelector over an iframe does not work properly in IE 7, Opera 9

Reported by: eternoendless Assigned to: sam
Priority: normal Milestone: 2.x
Component: Prototype Version: edge
Severity: major Keywords:
Cc:

Description

Accessing elements form the document of an iframe using Element.getElementsBySelector(frameDoc,cssSelector) doesn't work as expected in IE 7 and Opera 9, while it does work on Firefox 2 and Safari (Windows).

On IE 7, it fails fetching elements with id selectors, as in "#elemID" or "#elemID chidlElem", and always returns an empty string, while if using className or tagName selectors such as ".myClass" and "div" it works fine. On Opera 9, it dies with unhandled exception [Object DOMException] "WRONG_DOCUMENT_ERR".

var frame = (frames['testframe']) ? frames['testframe'].document : $('testframe').contentDocument;
// test that the element exists and is accessible by the browser
alert('getElementsByTagname(div): '+frame.getElementsByTagName('div')); 
// fetch by id
alert('selector #testDiv: '+Element.getElementsBySelector(frame,'#testDiv')); 
// fetch by tagname
alert('selector div: '+Element.getElementsBySelector(frame,'div')); 

This is so on Prototype 1.5.1 and 1.6.0_rc0

Attachments

one.html (0.9 kB) - added by eternoendless on 09/13/07 15:10:48.
two.html (353 bytes) - added by eternoendless on 09/13/07 15:11:21.
prototype.js (120.7 kB) - added by eternoendless on 09/13/07 15:11:40.

Change History

09/13/07 15:10:48 changed by eternoendless

  • attachment one.html added.

09/13/07 15:11:21 changed by eternoendless

  • attachment two.html added.

09/13/07 15:11:40 changed by eternoendless

  • attachment prototype.js added.

03/29/08 07:12:36 changed by jdalton

03/29/08 07:12:53 changed by jdalton

  • status changed from new to closed.
  • resolution set to duplicate.