+ 2

How to implement javascript into html??

here i am new to the java language.. i want to implement javascript in html page.. what should i do?? please suggest me

5th Jun 2017, 10:32 AM
Sultan Belai
Sultan Belai - avatar
3 odpowiedzi
+ 4
Java or JavaScript? They are not the same language. JavaSript can be included right within the HTML file with <script> tags, usually in <head> section. However, it's good practice to keep JavaScript in its own file, same with CSS. You can implement JS from an external file by adding a script tag like so: <html> <head> <script type="text/javascript" src="path/to/your_script_file.js" ></script> </head> <body> <!-- Content goes here --> </body> </html>
5th Jun 2017, 10:49 AM
Taija
Taija - avatar
+ 3
Since Html5, 'type' attribute of <script> elements is no more mandatory, so you can write shortener: <script src="url/to/your/script/file.js"></script> Anyway, by this way you link an external JS file. You can also include inlined (embeded) JS code directly into Html source, by placing it as content of <script> element: <script> /* some JavaScript code */ </script> <script> elements can be placed (linked as inlined) anywhere in the Html source... The only difference wich will occurs is the moment when the JS code will be loaded/parsed/ran: as default behaviour is to be synchrone, it would have some incidence (more or less, depending of context) to load time, wait time, ... before displaying content ^^
5th Jun 2017, 2:29 PM
visph
visph - avatar
+ 1
thanks man!! its very helpful to me..
5th Jun 2017, 10:56 AM
Sultan Belai
Sultan Belai - avatar