jquery在线网站URL网址Ping工具插件

所属分类: 网页特效-实用工具    2023-11-21 08:53:25

jquery在线网站URL网址Ping工具插件 ie兼容6
反馈问题  查看演示  登录后下载 温馨提示
登录会员即可享受免费下载
 我要建站

jquery在线网站URL网址Ping工具插件(共3个文件)

    • ping.js
    • runping.js
    • index.html

使用方法

var Ping = function(opt) {
    this.opt = opt || {};
    this.favicon = this.opt.favicon || "/favicon.ico";
    this.timeout = this.opt.timeout || 0;
    this.logError = this.opt.logError || false;
};

Ping.prototype.ping = function(source, callback) {
    var self = this;
    self.wasSuccess = false;
    self.img = new Image();
    self.img.onload = onload;
    self.img.onerror = onerror;

    var timer;
    var start = new Date();

    function onload(e) {
        self.wasSuccess = true;
        pingCheck.call(self, e);
    }

    function onerror(e) {
        self.wasSuccess = false;
        pingCheck.call(self, e);
    }

    if (self.timeout) {
        timer = setTimeout(function() {
            pingCheck.call(self, undefined);
    }, self.timeout); }


    /**
     * Times ping and triggers callback.
     */
    function pingCheck() {
        if (timer) { clearTimeout(timer); }
        var pong = new Date() - start;

        if (typeof callback === "function") {
            // When operating in timeout mode, the timeout callback doesn't pass [event] as e.
            // Notice [this] instead of [self], since .call() was used with context
            if (!this.wasSuccess) {
                if (self.logError) { console.error("error loading resource"); }
                return callback("error", pong);
            }
            return callback(null, pong);
        }
    }

    self.img.src = source + self.favicon + "?" + (+new Date()); // Trigger image load with cache buster
};

if (typeof exports !== "undefined") {
    if (typeof module !== "undefined" && module.exports) {
        module.exports = Ping;
    }
} else {
    window.Ping = Ping;
}

站长提示:
1. 平台上所有素材资源,需注册登录会员方能正常下载。
2. 会员用户积极反馈网站、素材资源BUG或错误问题,每次奖励20K币
3. PHP源码类素材,如需协助安装调试,或你有二次开发需求,可联系苦力吧客服。
4. 付费素材资源,需充值后方能下载,如有任何疑问可直接联系苦力吧客服
相关资源 / 实用工具

jquery简易版在线记事本工具插件

一款简单的在线记事本应用程序,可记录笔记或书写短文等,可保存下来供日后使用。
  实用工具
 211  

jquery支持移动、缩放、倾斜、旋转的图片编辑器

一款在线图片编辑工具,支持图片各种操作:旋转、倾斜、缩放和平移等功能,带可拖动的进度滑块。
  实用工具
 225  

基于javascript实现检测浏览器名称和版本参数信息

这是一款获取访客用户浏览器版本信息工具,它还支持Chrome和Firefox浏览器兼容性检查,以便提醒用户获得更流畅的浏览体验。
  实用工具
 194  

jquery点击按钮可放大缩小页面插件

可自由放大缩小整个页面,使得页面元素:图片、文字等同步达到放大缩小效果。
  实用工具
 184  

评论数(1) 回复有机会获得K币 用户协议

    great0
    2023-12-07 21:22:59
😀
  • 😀
  • 😊
  • 😂
  • 😍
  • 😑
  • 😷
  • 😵
  • 😛
  • 😣
  • 😱
  • 😋
  • 😎
  • 😵
  • 😕
  • 😶
  • 😚
  • 😜
  • 😭
发表评论