I am trying to validate the JavaScript on my website. The scripts do not throw any errors and run fine on Chrome and Firefox (latest stable version). However, the animated parts absolutely do not work on IE (9)[*1][*solved]. I have used jQuery and jQueryUI for the animation and had hoped that it would be cross browser compatible.

Usually I would not have cared abut IE users, but liked the idea of folks at anybrowser.org and thought of sticking to a standard instead of using the lowest common denominator and leave the graceful degradation to the browsers / JS engines. My page is HTML5 compliant according to the w3c validator and I wanted to do the same with JavaScript, but could not find an acceptable way to do it.

Why JSLint did not work -

  1. It will not take the page and check it like w3c validator.
  2. So there is no way to check jQuery referenced script. (There are a few SO posts on this).

I did find an ECMA-264 test page that would check the browser, but not my JavaScript.

The question after all the preamble is: How do I validate the Javascript on my webpage? Is there an authoritative validator for JavaScript?

*1 Added: The minification has nothing to do with the script not working on IE9. Even the unminified version does not work.

*Solved: The problem with the specific page was solved by this comment.


This started as "What is Javascript?" got closed here and migrated to Programmers. Thanks to YannisRizos for helping me to split the original question to something that was acceptable between Programmers and SO.

有帮助吗?

解决方案

A test suite. No really.

If you want to ensure your javascript runs perfectly in every target environment, then you write a test suite for your code and make sure it passes in all your target environments.

A test suite helps find where your code breaks when run on different platforms. And therefore helps you fix it.


But assuming you want something that is less work, http://www.jshint.com/ is your best bet.

Or http://www.jslint.com/ if you like getting yelled at.

But honestly, no validator will ever be able to ensure that your code runs without error and exactly how you expect everywhere. Simply because your code follows best practices correctly, that doesn't mean it will work in an old version of IE.

Standards evolve, but an old browser that never updates get stuck with whatever standard was out at the time that the browser maker may or may not have even implemented successfully or accurately.

Testing, automated or manual, is the only way to ensure things work universally.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top