Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix #401 HashManager works correctly in IE7 even after a domain change

In order to provide support for back and forward in hash-based navigation in Internet Explorer 7, class aria.utils.HashManager creates a hidden iframe to open and close each time the history has to be populated with an entry.

When the document.domain is changed, IE7 denies access to some global variables of the iframe, unless the document.domain is updated inside the iframe, too. In order to notify that document.domain has been explicly set, variable Aria.domain has to be set to the same value.
  • Loading branch information...
commit 1e5e3ed9318fff3e76424007722bbe3f27bbc7f8 1 parent 2563d43
@flongo flongo authored
View
2  build/config/jshint.json
@@ -43,7 +43,7 @@
"onecase" : false,
"proto" : true,
"regexdash" : true,
- "scripturl" : false,
+ "scripturl" : true,
"smarttabs" : false,
"shadow" : true,
"sub" : true,
View
10 src/aria/Aria.js
@@ -483,6 +483,16 @@
Aria.memCheckMode = Aria.memCheckMode === true;
/**
+ * The domain variable has to be set only when you explicitly set the value of document.domain. It is needed by
+ * classes using iframes (like aria.utils.HashManager) in order to overcome the limitations imposed by IE6/7 on the
+ * access of the iframe contents. It is desirable to set it at the very beginning, even before loading the bootstrap
+ * file of the framework.
+ * @type String
+ * @name Aria.domain
+ */
+ Aria.domain = Aria.domain || null;
+
+ /**
* Prefix used for all parameters added in objects by the framework for internal requirements
* @type String
* @name Aria.FRAMEWORK_PREFIX
View
31 src/aria/utils/HashManager.js
@@ -120,6 +120,12 @@ Aria.classDefinition({
*/
this._currentIframeHashString = null;
+ /**
+ * Polled hash string retrieved from the iframe
+ * @type String
+ */
+ this.polledIframeHashString = null;
+
if (this._isIE7OrLess) {
this._createIframe();
}
@@ -173,6 +179,7 @@ Aria.classDefinition({
* @param {Object} window Window whose hash to set. It defaults to Aria.$window.
*/
setHash : function (arg, window) {
+ arg = arg || "";
window = window || Aria.$window;
var newHashString = "";
if (this._typeUtil.isObject(arg)) {
@@ -198,7 +205,7 @@ Aria.classDefinition({
addCallback : function (cb) {
if (this._hashChangeCallbacks == null) {
this._hashChangeCallbacks = [];
- //aria.utils.AriaWindow.attachWindow();
+ // aria.utils.AriaWindow.attachWindow();
this._addHashChangeInternalCallback();
}
this._hashChangeCallbacks.push(cb);
@@ -220,7 +227,7 @@ Aria.classDefinition({
if (hcC.length === 0) {
this._hashChangeCallbacks = null;
this._removeHashChangeInternalCallback();
- //aria.utils.AriaWindow.detachWindow();
+ // aria.utils.AriaWindow.detachWindow();
}
}
}
@@ -367,9 +374,11 @@ Aria.classDefinition({
scope : this,
delay : this.ie7PollDelay
});
- var iframeWindow = this._iframe.contentWindow;
+
var documentHash = this.getHashString();
- var iframeHash = this.getHashString(iframeWindow);
+
+ var iframeHash = this.polledIframeHashString;
+
// back or forward
if (iframeHash != this._currentIframeHashString) {
this._currentIframeHashString = iframeHash;
@@ -506,17 +515,23 @@ Aria.classDefinition({
* @protected
*/
_addIframeHistoryEntry : function (hash) {
-
var iframe = this._iframe;
if (!iframe) {
return;
}
hash = hash || "";
if (this._currentIframeHashString != hash) {
- iframe.contentWindow.document.open();
- iframe.contentWindow.document.close();
+ var src = ['javascript:document.open();'];
+ src.push('document.write(\"<script type=\\\"text/javascript\\\">');
+ if (Aria.domain) {
+ src.push('document.domain=\\\"' + Aria.domain + '\\\";');
+ }
+ src.push('if (parent.' + this.$classpath + '){parent.' + this.$classpath
+ + '.polledIframeHashString=\\\"' + hash + '\\\";}');
+ src.push("</script>\");");
+ src.push('document.close();');
+ iframe.src = src.join("");
this._currentIframeHashString = hash;
- this.setHash(hash, iframe.contentWindow);
}
},
Please sign in to comment.
Something went wrong with that request. Please try again.