html中的哪个功能我可以用来做到...当我打开网站并脱机时,它会显示出"您处于脱机状态,请打开Internet连接到运行网站。"
您可以使用window
offline
事件
window.addEventListener('offline', function(event){
alert("You are offline please turn on internet connection to run website");
});
尝试一下。
var online = navigator.onLine;
if (online == false)
{
alert("Sorry, we currently do not have Internet access.");
location.reload();
}