Side navigation
#6500 closed bug (worksforme)
Opened April 28, 2010 03:54PM UTC
Closed June 15, 2010 01:37AM UTC
document.domain + IE6 + jQuery 1.4.x = "Permission denied" error
Reported by: | cowboy | Owned by: | |
---|---|---|---|
Priority: | Milestone: | 1.4.3 | |
Component: | unfiled | Version: | 1.4.2 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
After setting document.domain
, I get a "Permission denied" error when accessing the location.hash
properties immediately or in DOM ready in IE6 if jQuery 1.4.x is included in the page.
Test-cases:
- jQuery 1.4.2: http://benalman.com/code/test/jquery-142-document-domain-ie6.html
- jQuery 1.3.2: http://benalman.com/code/test/jquery-132-document-domain-ie6.html
Sample code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.js"></script> <script type="text/javascript"> document.domain = document.domain.split('.').slice(-2).join('.'); var results = []; // Error! try { results.push( 'Immediate: ' + location.href ); } catch(e) { results.push( 'Immediate: ' + e.message ) } // Error when executed in the body, but not in the head! $(function(){ try { results.push( 'DOMready: ' + location.href ); } catch(e) { results.push( 'DOMready: ' + e.message ) } }); // No error! setTimeout(function(){ try { results.push( 'setTimeout: ' + location.href ); } catch(e) { results.push( 'setTimeout: ' + e.message ) } }, 100); setTimeout(function(){ alert( results.join( "\\n---\\n" ) ); }, 1000); </script>
Attachments (0)
Change History (11)
Changed April 28, 2010 04:03PM UTC by comment:1
Changed April 28, 2010 04:11PM UTC by comment:2
And as I said in my code comments, I get slightly different results depending on whether all this code is in the head vs the body.
Changed April 28, 2010 04:19PM UTC by comment:3
For me, i get permission denied for all three (Immediate, DOMReady, and setTimeout) for both 1.3.2 and 1.4.x in IE7.
I get the same behavior in IE6 that "cowboy" describes--error, error, success w/ 1.4, and success, success, success in 1.3.2.
Changed April 28, 2010 04:27PM UTC by comment:4
my results on M$ VirtualPC images for IE6
Changed April 28, 2010 04:30PM UTC by comment:5
my results on M$ VirtualPC images for IE7
Changed April 29, 2010 09:14AM UTC by comment:6
Tested with:
Internet Explorer 6 (6.0.2900.5512.xpsp.080413-2111)
Windows XP SP3
VirtualBox 3.1.6
Getting some freaky results here...
JQUERY 1.4.2:
IE6 (1st time)
Immediate: ERROR
DOMready: success
setTimeout: success
(page reload after 1st try)
Immediate: ERROR
DOMready: ERROR
setTimeout: ERROR
(close browser, 2nd try)
Immediate: ERROR
DOMready: success
setTimeout: success
(reload after 2nd try)
Immediate: success
DOMready: success
setTimeout: success
(close browser, empty cache, 3rd try)
Immediate: ERROR
DOMready: ERROR
setTimeout: success
(reload after 3rd try)
Immediate: success
DOMready: success
setTimeout: success
JQUERY 1.3.2:
IE6 (1st time)
Immediate: success
DOMready: success
setTimeout: success
Every reload using 1.3.2 gives different results. I've had 1x ERROR, 2x ERROR, 3x ERROR and all success with no apparent pattern. But the first load after closing the browser is always 3x succes.
Changed May 03, 2010 06:57PM UTC by comment:7
I wasn't using .splice correctly in my initial examples. I have since fixed my tests, but they still fail (albeit, in different places) for me in IE6 and IE7 (and work perfectly in IE8):
jQuery 1.4.2
http://benalman.com/code/test/jquery-142-document-domain-fixed.html
jQuery 1.3.2
http://benalman.com/code/test/jquery-132-document-domain-fixed.html
JQUERY 1.4.2:
IE6
Immediate: ERROR
DOMready: ERROR
setTimeout: ERROR
IE7
Immediate: ERROR
DOMready: success
setTimeout: success
JQUERY 1.3.2:
IE6
Immediate: ERROR
DOMready: ERROR
setTimeout: ERROR
IE7
Immediate: success
DOMready: success
setTimeout: success
Changed May 04, 2010 09:45AM UTC by comment:8
My results on the fixed test.
JQUERY 1.4.2:
IE6
Immediate: ERROR
DOMready: ERROR
setTimeout: ERROR
Reloading the page gives random results. There has to be some kind of race condition here...
JQUERY 1.3.2:
IE6
Immediate: success
DOMready: success
setTimeout: success
Reloads keep returning success
Changed May 24, 2010 01:30PM UTC by comment:9
So, this seems to be a non-issue, but only when document.domain is set BEFORE jQuery is loaded! (thanks to @jaubourg for suggesting this approach)
jQuery 1.4.2
http://benalman.com/code/test/jquery-142-document-domain-before.html
jQuery 1.3.2
http://benalman.com/code/test/jquery-132-document-domain-before.html
Feel free to confirm!
Changed May 25, 2010 09:24AM UTC by comment:10
Verified on my IE6 test image. Both jQuery 1.3 and 1.4 tests work perfectly. Reloads work as well.
Changed June 15, 2010 01:37AM UTC by comment:11
resolution: | → worksforme |
---|---|
status: | new → closed |
I'll close this, sounds like there's a simple workaround.
It's not just IE6, but IE7 too. IE8 and IE8-compat mode seem to work fine. My observations:
jQuery 1.4.2:
IE6
IE7
jQuery 1.3.2:
IE6
IE7