Welcome to JavascriptHero, You are at perfect place
to give a perfect start on javascript. In this tutorial we will
learn about inline,header and external javascript.
What is Inline Javascript?
Inline Javascript is a javascript written in same line wherever needed.
for example:
<button onclick="alert('hello from inline javascript');">Inline</button>
Here clicking on this button we like to display alert message. Which is written in same line.
What is header section javascript?
Header section javascript is a javascript code
which is called upon doing some event like clicking button.
For example:
<button onclick="show()">header</button>
Here show() method is executed on cliking this button.
What is external Javascript?
External javascript is a javascript written in .js (dot js) format.
External javascript can be used in multiple pages.
For example:
<button onclick="external()">External</button>
Here external function of external.js is executed.
What to put in external file?
Name it external.js & insert code:
function external()
{
alert("A message from external.js file");
}
The Full code is as follows:
<html>
<head>
<title>
Inline , header and external javascript
</title>
<script src="external.js"></script>
<script>
function show()
{
alert("hello from header section javascript");
}
</script>
</head>
<body>
<button onclick="alert('hello from inline javascript');">Inline</button>
<button onclick="show()">header</button>
<button onclick="external()">External</button>
</body>
</html>
A video tutorial related to this article is here in which you will be more clear.
Thanks for visiting my blog. If you are interested in other stuffs like C#, ASP MVC
You can visit my blog:
https://ythecoder.blogspot.com
to give a perfect start on javascript. In this tutorial we will
learn about inline,header and external javascript.
What is Inline Javascript?
Inline Javascript is a javascript written in same line wherever needed.
for example:
<button onclick="alert('hello from inline javascript');">Inline</button>
Here clicking on this button we like to display alert message. Which is written in same line.
What is header section javascript?
Header section javascript is a javascript code
which is called upon doing some event like clicking button.
For example:
<button onclick="show()">header</button>
Here show() method is executed on cliking this button.
What is external Javascript?
External javascript is a javascript written in .js (dot js) format.
External javascript can be used in multiple pages.
For example:
<button onclick="external()">External</button>
Here external function of external.js is executed.
What to put in external file?
Name it external.js & insert code:
function external()
{
alert("A message from external.js file");
}
The Full code is as follows:
<html>
<head>
<title>
Inline , header and external javascript
</title>
<script src="external.js"></script>
<script>
function show()
{
alert("hello from header section javascript");
}
</script>
</head>
<body>
<button onclick="alert('hello from inline javascript');">Inline</button>
<button onclick="show()">header</button>
<button onclick="external()">External</button>
</body>
</html>
A video tutorial related to this article is here in which you will be more clear.
Thanks for visiting my blog. If you are interested in other stuffs like C#, ASP MVC
You can visit my blog:
https://ythecoder.blogspot.com