Ticket #10570 (closed bug: fixed)
:text selector throws an error in IE7 when there is a cross domain iframe on the page
| Reported by: | matt@… | Owned by: | timmywil |
|---|---|---|---|
| Priority: | low | Milestone: | 1.8 |
| Component: | selector | Version: | 1.6.4 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
This bug origins in Sizzle, there is already a bug report there ( https://github.com/jquery/sizzle/issues/66), but since nothing happened there during the last three months, I think it's apropriate to file a bug report here as well, since jQuery is directly affected by this bug.
When there is an iframe with a cross domain source, the :text selector fails in IE7 with the error "Permission denied". The problem lies in line 4394 (jQuery 1.6.4):
var attr = elem.getAttribute( "type" ), type = elem.type;
For some reason, getAttribute("type") is not allowed on cross domain iframes in IE7. A possible solution would be to only check the attribute when the element indeed is an input element:
text: function( elem ) {
var attr, type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && (type = elem.type, attr = elem.getAttribute("type"), "text" === type) && ( attr === type || attr === null );
},
See http://jsfiddle.net/VvnGm/ for an example
Change History
comment:2 Changed 19 months ago by addyosmani
- Priority changed from undecided to low
- Status changed from new to open
- Component changed from unfiled to selector
comment:3 Changed 19 months ago by timmywil
- Owner set to timmywil
- Status changed from open to assigned
- Milestone changed from None to 1.next
comment:4 Changed 15 months ago by ko
I've got the same problem - in my case the cross domain iframe is facebook widget.
comment:6 Changed 13 months ago by matt@…
A workaround is to add this in a file just after jquery:
if ($.browser.msie && $.browser.version === "7.0") {
$.find.selectors.filters.text: function( elem ) {
var attr, type;
// IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc)
// use getAttribute instead to test this case
return elem.nodeName.toLowerCase() === "input" && (type = elem.type, attr = elem.getAttribute("type"), "text" === type) && ( attr === type || attr === null );
};
}
comment:7 Changed 11 months ago by timmywil
- Status changed from assigned to closed
- Resolution set to fixed
- Milestone changed from 1.next to 1.8
This has been implemented in 1.8.
comment:8 Changed 6 months ago by Mahesh Badmanji
Hi All , I have been struggling for this to get solution. Finally i got the issue and solution. This issue exists only in IE7 and IE9 compatibility view. Problem: In your page when you have an IFRAME with crossdomain source and suppose for example you have a jquery logic to get all ":input" elements , that time jquery loops through all the elements in the page and gets the "type" attibute, but when it hits the IFRAME element to get the type attibute it throws error "PERMISSION DENIED" since IFRAME has crossdomain source.
Solution: Just add dummy type attribute to your IFRAME tag and get rid of error
ex.
<iframe type="MyFrame" src=" http://www.xyz.com/iframe/customer-success-resources.html"/></iframe>
Hope this helps for those who are looking for solution.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

I'm seeing a similar problem at line 4125. Like yours, this has to do with cross-domain iframe only.
Will try to post a bug report later.