/**
* URL Watcher(require jQuery)
* 监测url的变化
* useage:
* UrlWatcher.init(50);
* UrlWatcher.AddListener(function(url,isFirstLoad){
* FrontEngine.generateFront();
* });
*
*/
var UrlWatcher = {
"init": function (waittime) {
this.UrlArray = [window.location.href];//set current url as default
this.ListenerArray = [];
this.ResetWaitTime(waittime);
},
"AddListener": function (listener) {//add a process function
this.ListenerArray.push(listener || function () {});
},
"DeleteListener": function () {
this.ListenerArray = [];
},
"ResetWaitTime": function (time) {//start timer
if (this.IntervalHandle) {window.clearInterval(this.IntervalHandle); }
this.WaitTime = time || 1000;
this.IntervalHandle = window.setInterval(this.ListenerCall.setThis(this), this.WaitTime);
},
"ListenerCall": function () {
var self = this, url = window.location.href;
if (self.UrlArray[self.UrlArray.length - 1] === url) {return; }
window.clearInterval(this.IntervalHandle);
$.each(this.ListenerArray, function (c, listener) {
listener(url, self.UrlArray.length === 0);
});
this.UrlArray.push(url);
this.ResetWaitTime(this.WaitTime);
}
};
if( ('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8))
{ // 浏览器支持onhashchange事件
indow.onhashchange = hashChangeFire; // TODO,对应新的hash执行的操作函数
}
else
{ // 不支持则用定时器检测的办法
setInterval(function() {
var ischanged = isHashChanged(); // TODO,检测hash值或其中某一段是否更改的函数
if(ischanged)
{
hashChangeFire(); // TODO,对应新的hash执行的操作函数
}
},
150);
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有