Javascript is the most popular programming language used on internet. It is also extended in many other platforms for system administration/scripting/macro purposes. For example, WSH (Windows Script Hosting) supports Javascript.
The reason that it should be avoided whenever there is an alternative is that most browsers have their own Javascript implementation which might not be compatible. Most of the front-end enginneers nowadays need to consider the difference of Javascript in different browsers, such as IE, Firefox, Chrome etc.
Even if the Javascript code makes no difference on different browsers, the browsers have the configuration settings to disable the javascript. That is why <noscript>…</noscript> HTML tag is for.
Below is a simple example of Javascript that used to submits a search query, which should be replaced by general form submission.
1 2 3 4 5 6 7 8 | <script language='Javascript'> function updateURL(s) { location.href='?s=' + s; } </script> <input id="s" name="s" type="text" /> <input onclick="javascript:updateURL(document.getElementByID("s").value);" type="button" value="search" /> |
<script language='Javascript'> function updateURL(s) { location.href='?s=' + s; } </script> <input id="s" name="s" type="text" /> <input onclick="javascript:updateURL(document.getElementByID("s").value);" type="button" value="search" />
This can be easily replaced by using HTML form technique:
1 2 3 4 | <form method="GET"> <input name="s" type="text" /> <input type="submit" value="search" /> </form> |
<form method="GET"> <input name="s" type="text" /> <input type="submit" value="search" /> </form>
–EOF (The Ultimate Computing & Technology Blog) —
loading...
Last Post: Quick Examples on SED
Next Post: BASH For Loops
This post was written at Jun 12 2012.
It IS outdated, and now every modern browsers have Javascript as an default language.
This is not a problem unless people don’t upgrade their browser and always use internet explorer 9 or something..
Not anymore, lmao