0
我想使用jQuery中的history.js插件。代碼是:jQuery歷史和變量範圍
// Global
var History = window.History;
$(document).ready(function() {
History.Adapter.bind(window, 'statechange', function(){
console.log('Yeeeeeeaah!');
});
window.History.pushState(null, null, '#42'); // Yeeeeeeaah!
});
function anotherFunc() {
window.History.pushState(null, null, '#test'); // Nothing happens
}
範圍有什麼問題?
嗯我不確定這個插件,但通常事件是調用'popstate' – devnull69
你什麼時候調用anotherFunc()?是否在執行History.Adapter.bind之後? – rdamborsky