#10570 closed bug (fixed)
:text selector throws an error in IE7 when there is a cross domain iframe on the page
Reported by: | Owned by: | Timmy Willison | |
---|---|---|---|
Priority: | low | Milestone: | 1.8 |
Component: | selector | Version: | 1.6.4 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
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 (9)
comment:1 Changed 12 years ago by
comment:2 Changed 12 years ago by
Component: | unfiled → selector |
---|---|
Priority: | undecided → low |
Status: | new → open |
comment:3 Changed 12 years ago by
Milestone: | None → 1.next |
---|---|
Owner: | set to Timmy Willison |
Status: | open → assigned |
comment:4 Changed 11 years ago by
I've got the same problem - in my case the cross domain iframe is facebook widget.
comment:6 Changed 11 years ago by
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 years ago by
Milestone: | 1.next → 1.8 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
This has been implemented in 1.8.
comment:8 Changed 11 years ago by
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.
comment:9 Changed 10 years ago by
Thanks Mahesh! Was having the same issue and it was driving me nuts! ;)
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.