最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Browser support for JavaScript versions - Stack Overflow

programmeradmin5浏览0评论

We are starting a project and want to be cross-browser patible - this would seem to suggest that we need to ensure that the version of JavaScript we're using is works in all of the browsers we intend to support. Is the following a reasonable way to test to see what the JavaScript level works in each browser?

<script language="javascript1.0">alert("Your browser at least supports JavaScript 1.0");</script>
<script language="javascript1.1">alert("Your browser at least supports JavaScript 1.1");</script>
<script language="javascript1.2">alert("Your browser at least supports JavaScript 1.2");</script>
<script language="javascript1.3">alert("Your browser at least supports JavaScript 1.3");</script>
<script language="javascript1.4">alert("Your browser at least supports JavaScript 1.4");</script>
<script language="javascript1.5">alert("Your browser at least supports JavaScript 1.5");</script>
<script language="javascript1.6">alert("Your browser at least supports JavaScript 1.6");</script>
<script language="javascript1.7">alert("Your browser at least supports JavaScript 1.7");</script>
<script language="javascript1.8">alert("Your browser at least supports JavaScript 1.8");</script>

Obviously the list of tests could be extended as further JavaScript versions are released.

Is there a better way (or source) for this information?

By the way, I did see the Wikipedia page on JavaScript versions and it doesn't seem to correspond to the results I get when I run the code snippet above.

My results are:

Firefox 43.0.4 - reports as supporting JavaScript 1.0 through 1.5
IE 10.0.9200.17566 - reports as supporting JavaScript 1.1 through 1.3
Chrome Version 47.0.2526.111 m - reports as supporting JavaScript 1.0 through 1.7
Safari 5.1.7 (7534.57.2) - reports as supporting JavaScript 1.0 through 1.7
Opera 34.0.2036.50 - reports as supporting JavaScript 1.0 through 1.7

We are starting a project and want to be cross-browser patible - this would seem to suggest that we need to ensure that the version of JavaScript we're using is works in all of the browsers we intend to support. Is the following a reasonable way to test to see what the JavaScript level works in each browser?

<script language="javascript1.0">alert("Your browser at least supports JavaScript 1.0");</script>
<script language="javascript1.1">alert("Your browser at least supports JavaScript 1.1");</script>
<script language="javascript1.2">alert("Your browser at least supports JavaScript 1.2");</script>
<script language="javascript1.3">alert("Your browser at least supports JavaScript 1.3");</script>
<script language="javascript1.4">alert("Your browser at least supports JavaScript 1.4");</script>
<script language="javascript1.5">alert("Your browser at least supports JavaScript 1.5");</script>
<script language="javascript1.6">alert("Your browser at least supports JavaScript 1.6");</script>
<script language="javascript1.7">alert("Your browser at least supports JavaScript 1.7");</script>
<script language="javascript1.8">alert("Your browser at least supports JavaScript 1.8");</script>

Obviously the list of tests could be extended as further JavaScript versions are released.

Is there a better way (or source) for this information?

By the way, I did see the Wikipedia page on JavaScript versions and it doesn't seem to correspond to the results I get when I run the code snippet above.

My results are:

Firefox 43.0.4 - reports as supporting JavaScript 1.0 through 1.5
IE 10.0.9200.17566 - reports as supporting JavaScript 1.1 through 1.3
Chrome Version 47.0.2526.111 m - reports as supporting JavaScript 1.0 through 1.7
Safari 5.1.7 (7534.57.2) - reports as supporting JavaScript 1.0 through 1.7
Opera 34.0.2036.50 - reports as supporting JavaScript 1.0 through 1.7

Share Improve this question asked Jan 20, 2016 at 18:53 NeoheuristNeoheurist 3,4847 gold badges41 silver badges59 bronze badges 6
  • P.S. given my test results it would seem that JavaScript 1.3 is the mon denominator for the latest versions of the browsers listed above... – Neoheurist Commented Jan 20, 2016 at 18:54
  • 1 kangax.github.io/pat-table/es6 – Random Logic Commented Jan 20, 2016 at 18:59
  • Before you do that, try to ask yourself this question: what is different between all those versions of JavaScript? All browsers these days basically support all < ES6 syntaxes. Is it really necessary to differentiate them? – Derek 朕會功夫 Commented Jan 20, 2016 at 19:05
  • The responses thus far prompted further research as to what was really going on with the script blocks that I listed above - apparently the language attribute is deprecated in favor of type where type would be expected to be application/javascript or not even referenced because javascript is considered the defacto scripting language for web pages. Therefore I'm left to conclude that the fact that my script blocks (above) seem to generate results that might be interpreted as meaningful, there is in fact no real meaning to be inferred... therefore the behavior should be considered as vestigial? – Neoheurist Commented Jan 20, 2016 at 19:45
  • 2 Downvotes on questions mean: This question does not show any research effort; it is unclear or not useful. It can also mean anything else. – Random Logic Commented Jan 20, 2016 at 20:14
 |  Show 1 more ment

1 Answer 1

Reset to default 8

Is the following a reasonable way to test to see what the JavaScript level works in each browser?

No.

Don't use the [language] attribute, it's only going to cause you inpatibility, especially as time goes on and newer browsers decide they only support javascript3.8 or whatever the version-du-jour happens to be. If you want to write a script, just write a script:

<script src="filename.js"></script>

As far as detecting versions, you don't need to detect JS versions. No developer worth their salt checks versions, they check features. Modernizr is one such feature detection resource. caniuse is another which describes which browsers support which features so you can determine if you're going to be able to use any particular feature at all.

In many cases, what you'll want for maximum backwards patibility is a set of polyfills to replicate any newer features you'd like to use for older browsers.

发布评论

评论列表(0)

  1. 暂无评论