哪些网络浏览器不支持 Javascript?以及如何识别客户端使用的是哪个浏览器?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6398447/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 20:32:32  来源:igfitidea点击:

What web browsers do not support Javascript? and how to identify which browser is client using?

javascriptbrowser

提问by love Computer science

are there any web browsers that do not support javascript? and how to identify if client is using one of those browsers? or client has disabled javascript?

是否有不支持 javascript 的网络浏览器?以及如何确定客户端是否正在使用这些浏览器之一?或客户端已禁用 javascript?

回答by Darin Dimitrov

are there any web browsers that do not support javascript?

是否有不支持 javascript 的网络浏览器?

Of course. Lynxis just one example.

当然。山猫只是一个例子。

and how to identify if client is using one of those browsers?

以及如何确定客户端是否正在使用这些浏览器之一?

Using the <noscript>tag to provide alternate content.

使用<noscript>标签提供替代内容。

or client has disabled javascript?

或客户端已禁用 javascript?

Same answer as previous : using the <noscript>tag.

与之前的答案相同:使用<noscript>标签。

You should never test if a client is using X or Y browser. Always perform feature detection. Step one: use <noscript>for providing alternate content to clients that do not support javascript. Then test whether the client supports the feature you would like to use. Never test if IE8 or FF3 or something else, ...

您永远不应该测试客户端是否使用 X 或 Y 浏览器。始终执行特征检测。第一步:<noscript>用于向不支持 javascript 的客户端提供替代内容。然后测试客户端是否支持您要使用的功能。永远不要测试 IE8 或 FF3 或其他东西,...

Modernizris an excellent framework which could aid you with this. So if you want to use some of the new cool HTML5 features, don't test if the browser is such and such version: test if the browser supports the feature you would like to use.

Modernizr是一个出色的框架,可以帮助您解决这个问题。所以如果你想使用一些新的很酷的 HTML5 特性,不要测试浏览器是否是这样那样的版本:测试浏览器是否支持你想要使用的特性。

回答by l2aelba

As if you will working with CSS :

就好像您将使用 CSS 一样:

Many adding no-jsclass in <html>tag like..

许多no-js<html>标签中添加类,如..

<html class="no-js">

and they do replace no-jsto jsby javascript later, like..

并且他们稍后会替换no-jsjsjavascript,例如..

<script>
    document.documentElement.className = document.documentElement.className.replace('no-js','js');
</script>

So when client has disabled javascript.

所以当客户端禁用了 javascript 时。

Example use :

示例使用:

HTML :

HTML :

<div class="test">This box with some JS function</div>

CSS :

CSS :

.no-js .test {display:none;}

Hide this box, when client has disabled javascript.

当客户端禁用 javascript 时隐藏此框。

or..

或者..

HTML :

HTML :

<div class="alert">Please, turn you JS on!</div>

CSS :

CSS :

.js .alert {display:none;}

Hide alert box when JS is on. But still show when JS if off..

当 JS 开启时隐藏警告框。但是如果关闭 JS 时仍然显示..

Or do something many more... with no-jsor jsclasses..

或者做更多的事情......与no-jsjs类..

If your looking for HTML tag for detection :

如果您正在寻找用于检测的 HTML 标记:

just <noscript></noscript>as another say

只是<noscript></noscript>另一个说

回答by James Allardice

All of the modern major browsers support JavaScript. There are however some that do not, but with an incredibly small user base relative to the main ones. Some users may disable JavaScript, in which case you can specify different content for those users using noscripttags.

所有现代主流浏览器都支持 JavaScript。然而,有些没有,但与主要用户群相比,用户群非常小。某些用户可能会禁用 JavaScript,在这种情况下,您可以使用noscript标签为这些用户指定不同的内容。

回答by JMax

Do you use any javascript framework ? (jquery, prototype...) They can abstract a big part of browser specificities.

你使用任何 javascript 框架吗?(jquery,prototype...) 他们可以抽象出浏览器特性的很大一部分。

To detect user browser, you can use the navigator object : http://www.javascriptkit.com/javatutors/navigator.shtml

要检测用户浏览器,您可以使用导航器对象:http: //www.javascriptkit.com/javatutors/navigator.shtml

And, as James and Darin pointed out, you can use the <noscript>tag for alternate content.

而且,正如 James 和 Darin 指出的那样,您可以将<noscript>标签用于替代内容。