简体   繁体   English

用于 IE7 的 hashchange polyfill,可以在每个刻度上跟踪多个事件

[英]hashchange polyfill for IE7 that can track more than one event per tick

I need to fire a hash change event more than once per tick.我需要在每个滴答声中多次触发哈希更改事件。

My current polyfill looks like this.我目前的 polyfill 看起来像这样。

//If the hashchange event is missing implement it
hashchangeSupported || (function() {

    //save the current hash for reference next cycle
    var lastHash = location.hash;

    //check the hash for changes every tick
    setInterval(function() {

        //if the hash is different since the last tick then
        // fire a hash change event.
        if(lastHash !== location.hash) {
            trigger('hashchange', window);
            lastHash = location.hash;
        }
    }, 1);
});

The problem is that if the hash is updated more than once per tick it still only fires a single hash change event.问题是,如果每个刻度更新哈希不止一次,它仍然只会触发单个哈希更改事件。 I'm looking for a way to check for changes more than once per tick.我正在寻找一种方法来检查每个刻度不止一次的变化。

I know this is asking a lot and I doubt its possible without getters and setters but I'm aware there are better programmers that I on Stack Overflow and I want some second opinions.我知道这要求很多,我怀疑没有 getter 和 setter 的可能性,但我知道我在 Stack Overflow 上有更好的程序员,我想要一些第二意见。

没有代理是不可能的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM