是否可以强制History.js - https://github.com/browserstate/History.js/ -在支持HTML5 5/历史API的浏览器中使用散列URL?
这仅用于本地测试,因此,如果需要的话,修改History.js源代码是可以的。
发布于 2012-03-01 14:17:55
为了测试目的,我也想做同样的事情,最后在jquery.history.js库中更新了下面的行。
()原版:
m.emulated={pushState:!Boolean(a.history&&a.history.pushState&&a.history.replaceState&&!/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(e.userAgent)&&!/AppleWebKit\/5([0-2]|3[0-2])/i.test(e.userAgent)),hashChange:Boolean(!("onhashchange"in a||"onhashchange"in d)||m.isInternetExplorer()&&m.getInternetExplorerMajorVersion()<8)}Hack解决方案:
m.emulated={pushState:true,hashChange:true}我使用的是HTML4+HTML5捆绑的小型化代码,但这一行对应于history.js未压缩文件中的第269行。如果您使用的是不同的版本,相应的部分如下:
():原版
History.emulated = {
pushState: !Boolean(
window.history && window.history.pushState && window.history.replaceState
&& !(
(/ Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i).test(navigator.userAgent) /* disable for versions of iOS before version 4.3 (8F190) */
|| (/AppleWebKit\/5([0-2]|3[0-2])/i).test(navigator.userAgent) /* disable for the mercury iOS browser, or at least older versions of the webkit engine */
)
),
hashChange: Boolean(
!(('onhashchange' in window) || ('onhashchange' in document))
||
(History.isInternetExplorer() && History.getInternetExplorerMajorVersion() < 8)
)
};Hack解决方案:
History.emulated = {
pushState: true,
hashChange: true
};https://stackoverflow.com/questions/9197048
复制相似问题