获得徽章 0
前端&全栈 @top10
#每天一个知识点#
前端同学看看这段代码,一定会收获很多编码灵感 #独创#

var _wr = function(type) {
var orig = history[type];
return function() {
var rv = orig.apply(this, arguments);
var e = new Event(type);
e.arguments = arguments;
window.dispatchEvent(e);
return rv;
};
};

history.pushState = _wr('pushState');

history.replaceState = _wr('replaceState');

window.addEventListener('replaceState', function(e) {
console.log('THEY DID IT AGAIN! replaceState 111111');
});

window.addEventListener('pushState', function(e) {
console.log('THEY DID IT AGAIN! pushState 2222222');
});

多看几遍,一定会有收获
展开
评论
下一页
个人成就
文章被点赞 69
文章被阅读 10,612
掘力值 716
收藏集
24
关注标签
40
加入于