Ajax を使用して、IE インスタンスを使用しているアプリケーションのインターネット接続を数秒ごとに確認しています。しかし、帯域幅が狭いため、インターネット エクスプローラーがクラッシュします。
Internet Explorer のクラッシュを防ぎ、パフォーマンスを向上させるために、インターネット接続を確認するためのベスト プラクティスは何ですか?
次のコードを使用して、インターネット接続を確認しています。
その説明は次の場所にあります: -
http://tomriley.net/blog/archives/111ここから jquery ファイルを取得します。
(function ($) {
$.fn.checkNet = function (intCheckInterval, strCheckURL) {
if (typeof (intCheckInterval) === 'undefined') {
var intCheckInterval = 5
} if (typeof (strCheckURL) === 'undefined') {
var strCheckURL = window.location
} else if (strCheckURL.indexOf('http') === -1) {
var strCheckURL = 'http://' + strCheckURL
} intCheckInterval = intCheckInterval * 1000; function doRequest(strCheckURL) {
$.ajax({ url: strCheckURL, cache: false, success: function () {
if ($('#netWarn').length) {
$('#netWarn').fadeOut()
} $('.tempDisabled').removeAttr('disabled').removeClass('tempDisabled')
}, error: function () {
if (!$('#netWarn').length) {
$('body').prepend('<p id="netWarn">No internet connection detected, some features will be re-enabled when a connection is detected. </p>'); $('#netWarn').fadeIn()
}
}
})
} setInterval(function () {
doRequest(strCheckURL)
}, intCheckInterval)
}
})(jQuery);