Opened 13 years ago
Closed 13 years ago
#6500 closed bug (worksforme)
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>
Change History (11)
comment:1 Changed 13 years ago by
comment:2 Changed 13 years ago by
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.
comment:3 Changed 13 years ago by
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.
comment:4 Changed 13 years ago by
my results on M$ VirtualPC images for IE6
1.4.2 http://gyazo.com/de413d08913bb2f55299149abb482f34.png
1.3.2 http://gyazo.com/b4fae7d18905f5e15cb2db57c58e8faa.png
comment:5 Changed 13 years ago by
my results on M$ VirtualPC images for IE7
1.4.2 http://gyazo.com/f3021d51e530d6f336f69fa20927fd0e.png 1.3.2 http://gyazo.com/e13102bbf1a7895c182192a8e62a1d81.png
comment:6 Changed 13 years ago by
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.
comment:7 Changed 13 years ago by
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
comment:8 Changed 13 years ago by
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
comment:9 Changed 13 years ago by
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!
comment:10 Changed 13 years ago by
Verified on my IE6 test image. Both jQuery 1.3 and 1.4 tests work perfectly. Reloads work as well.
comment:11 Changed 13 years ago by
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