我需要一些帮助来检测浏览器是否可以访问互联网
我一直在研究手册通过 CD 发送给客户。我公司的所有者要求将手册分为许多小节,作为 .doc 和 .docx 文件。本手册的目录将是一个 HTML 页面,当 CD 放入计算机时将通过自动运行来运行。
我可以相当确定该计算机是 Windows 计算机,但仅此而已。我目前的想法是使用这个脚本来利用google来显示word文件,但是仅当计算机实际连接到互联网时。这样我就不必依赖拥有特定版本的 word(或安装了兼容包)的客户。
根据我所做的研究,依靠计算机正确识别应使用word打开word文档的链接是有问题的,必须在用户端解决。
Possible Duplicate:
Check if Internet Connection Exists with Javascript?
I have been working on a manual to be sent via CD to a customer. The owner of my company requires that the manual be split into many subsections as .doc and .docx files. The table of contents for this manual will be an HTML page, to be run by autorun when the CD is put into the computer.
I can be fairly sure that the computer is a windows computer, but that's about it. My current thinking is to use this script to take advantage of google to display the word file, but only if the computer is actually connected to the internet. That way I don't have to rely on the customer having a particular version of word (or having a compatibility pack installed).
From the research I've done, relying on a computer to correctly recognize that a link to a word document should be opened with word is problematic, and has to be resolved at the user end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
看看 window.navigator.onLine
Have a look at window.navigator.onLine
您可以尝试向可靠的站点发出 ajax 请求。
现在您将不得不尝试使用它来使用响应,因为它是异步的,但这将有助于测试连接。
You could try an ajax request to a reliable site.
Now you will have to play around with it for a way to use the response because it is asynchronous, but this will work to test a connection.
之前在这里讨论过:使用 Javascript 检查 Internet 连接是否存在? 和此处:如何知道网络是否正常(断开)连接?。
Previously discussed here: Check if Internet Connection Exists with Javascript? and here: How to know if the network is (dis)connected?.
第二种选择
var HaveConnection = navigator.onLine;
second alternative
var HaveConnection = navigator.onLine;