jQuery哈希集功能

时间:2018-07-06 05:23:29

标签: jquery hash tabs hashchange

执行此行时,我需要调用一个函数

window.location.hash = "#globalSearchView";

当前我正在使用哈希更改功能

$(window).on("hashchange",function(e) {
    var hash = window.location.hash;
    switchtabs(hash);
});

仅在更改哈希值时有效,而在相同哈希值时无效。每当此行

时,我都想调用功能 switchtabs
window.location.hash = "#whatever";
不管是相同的哈希还是不同的哈希,都会执行

。谢谢

1 个答案:

答案 0 :(得分:0)

也许是吗?

var l = location.prototype;
Object.defineProperty(l, 'hash', {
  get: function() { return this.hash; },
  set: function(t) { this.hash = t; switchtabs(t); }
});