相关疑难解决方法(0)

popstate返回event.state未定义

我正在学习HTML5中的历史,在这个例子中(打开JavaScript浏览器控制台以查看错误)event.state.url返回:

Uncaught TypeError: Cannot read property 'url' of undefined
Run Code Online (Sandbox Code Playgroud)

看看和帮助:http://jsfiddle.net/un4Xk/

jquery html5 history pushstate

25
推荐指数
1
解决办法
2万
查看次数

jQuery绑定popstate事件未通过

我正在为History API编写一个小程序.我正在努力解决这个问题:

$(window).bind('popstate',  
    function(event) {
        console.log('pop: ' + event.state);
    });
Run Code Online (Sandbox Code Playgroud)

当我点击"上一步"按钮时,它会记录'pop:undefined'

但是,如果我这样做,事情就像预期的那样:

window.onpopstate = function(event) {
    console.log('pop: ' + event.state);
};
Run Code Online (Sandbox Code Playgroud)

它这次记录'pop:[object Object]'...

所以就像jQuery没有将事件对象传递给回调.
jQuery有问题吗?或者我弄乱了什么?

jquery html5 html5-history

25
推荐指数
1
解决办法
3万
查看次数

标签 统计

html5 ×2

jquery ×2

history ×1

html5-history ×1

pushstate ×1