Answers for "how to run javascript in html"

59

include script in html

<script type="text/javascript" src="/path/to/script.js"></script>
Posted by: Guest on July-17-2020
16

hello world javascript

// Output Hello World! in the console.
console.log("Hello World!");
Posted by: Guest on February-24-2020
1

html execute javascript

<!-- 
	Method 1: external script 
	- Should be placed in the <head> section of your HTML
	- The 'src' should contain the path to a local file or external URL
	- The 'defer' attribute will make it execute after the DOM is loaded
-->
<script src="script.js" type="text/javascript"></script>
<script src="script.js" type="text/javascript" defer></script>

<!-- 
	Method 2: inline code 
	- Should be placed in the <head> or <body> section of your HTML
 	- Place it before the </body> to make it execute after the DOM is loaded
-->
<script> alert("Hello world!"); </script>
Posted by: Guest on May-31-2021
6

javascript hello world

console.log("Hello World!");
Posted by: Guest on May-13-2020
0

insert js in html

<script src=¨script.js¨></script>
Posted by: Guest on August-22-2020
0

how to enter javascript in html

<script type="text/javascript">
  alert("This alert box was called with the onload event");
</script>
Posted by: Guest on August-19-2020

Code answers related to "how to run javascript in html"

Browse Popular Code Answers by Language