I work well with C#. Is it possible for a web page to receive its functionality from a non-JavaScript source? If so, why is it such a common practice to use JavaScript with HTML?
-
1Well it just depends on what the client supports. The browser is just a program that interprets what the server is sending. So if you're using an old version of internet explorer - VBScript can be used. It's a common practice to use JavaScript because it's widely supported. If you decided to make your own browser that supported some language you created - then you could use that language.Dave Chen– Dave Chen2017-08-12 05:32:58 +00:00Commented Aug 12, 2017 at 5:32
5 Answers
JavaScript is client-side. If you want some level of interactions in the client then JavaScript is the way to go. (You can also use JS server-side, and there are other client-side options as well, but JS is pretty much the de-facto standard for implementing client side interactions)
It's common because it's a standard. Nearly all (or all?) browsers support JavaScript these days. It was also one of the first browser-supported client-side scripting languages.
Comments
I'm pretty sure javascript is the only thing you can use on the front end. I guess you could implement flash or something but flash is dying out and shouldn't be used on the web.
Since you say you're well-versed in C#, you might want to look into ASP.NET. I don't know that much about it, but it's on the same framework as C# (well it should be judging by the name)
They don't have to use Javascript. But if they choose to use a client-side language, it will be Javascript. Because it's the only language browsers can run.
3 Comments
Yes, of course, you could run just HTML and CSS without a scripting language. But, if you want to use a scripting language, JavaScript is the only one that all major browsers understand.
In the early days of browsers there were some competing scripting languages but they were all dropped for JavaScript.
Comments
JavaScript is an example of a Client-side scripting language where the code is actively interpreted by the browser, which means the browser has to support the scripting language you choose. In HTML, the scripting language is defined by the type attribute within the <script> tag.
As of Html5, the default language for all script tags became JavaScript. However, w3.org shows these three examples as client-side scripts in an html page:
- text/vbscript
- text/tcl
- text/javascript
I would guess that almost everyone uses JavaScript because it is most widely supported by all the most popular browsers.
If you like C# or some other language, you can do something similar to server-side scripting in ASP.NET.