history-hash-ie-debug.js revision 4106577eb9389768607e9d9a51f614faa6bdb8bc
/**
* Improves IE6/7 support in history-hash by using a hidden iframe to create
* entries in IE's browser history. This module is only needed if IE6/7 support
* is necessary; it's not needed for any other browser.
*
* @module history
* @submodule history-hash-ie
* @since 3.2.0
*/
// Combination of a UA sniff to ensure this is IE (or a browser that wants us to
// treat it like IE) and feature detection for native hashchange support (false
// for IE < 8 or IE8/9 in IE7 mode).
HistoryHash = Y.HistoryHash,
/**
* Gets the raw (not decoded) current location hash from the IE iframe,
* minus the preceding '#' character and the hashPrefix (if one is set).
*
* @method getIframeHash
* @return {String} current iframe hash
* @static
*/
HistoryHash.getIframeHash = function () {
return '';
}
};
/**
* Updates the history iframe with the specified hash.
*
* @method _updateIframe
* @param {String} hash location hash
* @param {Boolean} replace (optional) if <code>true</code>, the current
* history state will be replaced without adding a new history entry
* @protected
* @static
* @for HistoryHash
*/
if (!iframeDoc || !iframeLocation) {
return;
}
if (replace) {
} else {
}
};
if (!iframe) {
Y.on('domready', function () {
// Create a hidden iframe to store history state, following the
// iframe-hiding recommendations from
//
// This iframe will allow history navigation within the current page
// context. After navigating to another page, all but the most
// recent history state will be lost.
//
// Earlier versions of the YUI History Utility attempted to work
// around this limitation by having the iframe load a static
// resource. This workaround was extremely fragile and tended to
// break frequently (and silently) since it was entirely dependent
// on IE's inconsistent handling of iframe history.
//
// Since this workaround didn't work much of the time anyway and
// added significant complexity, it has been removed, and IE6 and 7
// now get slightly degraded history support.
'<iframe src="javascript:0" style="display:none" height="0" width="0" tabindex="-1" title="empty"/>'
));
// Append the iframe to the documentElement rather than the body.
// Keeping it outside the body prevents scrolling on the initial
// page load (hat tip to Ben Alman and jQuery BBQ for this
// technique).
// Update the iframe with the initial location hash, if any. This
// will create an initial history entry that the user can return to
// after the state has changed.
// Listen for hashchange events and keep the iframe's hash in sync
// with the parent frame's hash.
Y.on('hashchange', function (e) {
lastUrlHash = e.newHash;
}
}, win);
Y.later(50, null, function () {
if (iframeHash !== lastUrlHash) {
}
}, null, true);
});
}
}