javascript – 浏览器嗅探
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了javascript – 浏览器嗅探,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1895字,纯文字阅读大概需要3分钟。
内容图文
![javascript – 浏览器嗅探](/upload/InfoBanner/zyjiaocheng/791/3e084b59f74949788931879afbc93379.jpg)
我知道browsersniffing不是为多个浏览器设计网站的正确方法.然而,我的问题与设计一个对每个浏览器表现良好的网站无关.
我想让用户能够将网站安装为webapp,如果浏览器是谷歌浏览器或Firefox 4,如果它是Opera的小部件,作为扩展,如果它是Safari …等等
基本上我想用一个提供这种安装的按钮滑入div.如果浏览器是例如Safari,则无法显示webapp解决方案,因为Safari不支持它.
那么我该如何以一种好的方式做到这一点呢?
我发现这是基于功能而不是使用
Safe feature-based way for detecting Google Chrome with Javascript?
var is = {
ff: window.globalStorage,
ie: document.all && !window.opera,
ie6: !window.XMLHttpRequest,
ie7: document.all && window.XMLHttpRequest && !XDomainRequest && !window.opera,
ie8: document.documentMode==8,
opera: Boolean(window.opera),
chrome: Boolean(window.chrome),
safari: window.getComputedStyle && !window.globalStorage && !window.opera
}
它似乎适合我的需要,而且很短,不笨重,或多或少是恶搞
解决方法:
看看jQuery.browser:http://api.jquery.com/jQuery.browser/
The $.browser property provides
information about the web browser that
is accessing the page, as reported by
the browser itself. It contains flags
for each of the four most prevalent
browser classes (Internet Explorer,
Mozilla, Webkit, and Opera) as well as
version information.Available flags are:
webkit (as of jQuery 1.4) safari
(deprecated) opera msie mozilla This
property is available immediately. It
is therefore safe to use it to
determine whether or not to call
$(document).ready(). The $.browser
property is deprecated in jQuery 1.3,
and its functionality may be moved to
a team-supported plugin in a future
release of jQuery.Because $.browser uses
navigator.userAgent to determine the
platform, it is vulnerable to spoofing
by the user or misrepresentation by
the browser itself. It is always best
to avoid browser-specific code
entirely where possible. The $.support
property is available for detection of
support for particular features rather
than relying on $.browser.
内容总结
以上是互联网集市为您收集整理的javascript – 浏览器嗅探全部内容,希望文章能够帮你解决javascript – 浏览器嗅探所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。