0

I learnt that the JavaScript syntax document.<a_form_name> is IE proprietary syntax (instead of document.forms.<a_form_name>). (reference: https://developer.mozilla.org/en-US/docs/Archive/Using_Web_Standards_in_your_Web_Pages/Using_the_W3C_DOM)

There are more other proprietary or dialect syntax, methods or functions on JavaScript/CSS/HTML. Most of the dialects are works fine in latest browsers, but I think clean code is better for future maintenance.

I could not find the lint checker to notice the problems like that. Do you have some tools or methodology to avoid or minimize the dialect from the JavaScript code?

  • I want to focus to find any tools or methodology to help this topic. thank you @ravi-nain , the JQuery is one of the solutions. – takahar tanak Mar 29 '20 at 05:21
  • What version of IE are you targeting? Recent versions (can confirm with 11 atm) should support `document.forms.myForm`. You really shouldn't have an large issue dealing with modern browsers in your development in 2020. (But yes, if it were 2010, jQuery would be the way to treat all browsers the same. In 2020, you would likely [transpile your JavaScript](https://babeljs.io/) to something suitable for your target browsers if it were an issue. That is, I think your question might indicate you're mired in issues most stacks left a decade ago! I'm interested in the use case. Legacy code?) – ruffin Sep 11 '20 at 20:45
  • Yes, I thought both `docuemnt.forms.myForm` and `document.myForm` are work on IE (IE only), and the second one is IE proprietary. – takahar tanak Jan 02 '21 at 04:31

1 Answers1

1

You can use libraries such as jquery to manage browser compatibility.

Checkout more details on this website: https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Cross_browser_testing/JavaScript

Some snippet from aforementioned website:

Historically, JavaScript was plagued with cross-browser compatibility problems — back in the 1990s, the main browser choices back then (Internet Explorer and Netscape) had scripting implemented in different language flavours (Netscape had JavaScript, IE had JScript and also offered VBScript as an option), and while at least JavaScript and JScript were compatible to some degree (both based on the ECMAScript specification), things were often implemented in conflicting, incompatible ways, causing developers many nightmares.

Such incompatibility problems persisted well into the early 2000s, as old browsers were still being used and still needed supporting. This is one of the main reasons why libraries like jQuery came into existence — to abstract away differences in browser implementations (e.g. see the code snippet in How to make an HTTP request) so developers only have to write one simple bit of code (see jQuery.ajax()). jQuery (or whatever library you are using) will then handle the differences in the background, so you don't have to.

Ravi Nain
  • 605
  • 8
  • 16