Monday, January 4, 2016

Inline, Header and External Javascript Methods

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

Javascript start from Hello World for beginners

Hello guys welcome to my first tutorial on javascript. You are at right place to jumstart on javascript.
Javascript is pretty much easy with some one's little guidance. Lets start our first program on javascript i.e Hello world program.

What this program or script does?
This hello world script display a hello world message in alert box. It display in two way one is directly on opening page and another on clicking on a button.

How it works?
It works with following code , just type it in notepad. Remember later we may have different editing tools for now you can practice in notepad or notepad++.The code is:
<html>
<head>
<title>
Javascript
</title>
<script>
function sayhello()
{
alert("Hello World");
}
</script>
</head>
<body>
<button onclick="sayhello()">Click It</button>
</body>
</html>

Here html tag starts our html page.
Head is a thinking part of our page which does logical work. It may contain scripts titles or css.
Title creates a page title 'Javascript'.
Script is starting our javascript.In which we can write our function or javascript codes.
Body is main or parent part of our page in which physical or visible things appear. Like here is a button.
Button tag is making a button. It contains a attribute called onclick which enables you to launch a function.

Finally
Thus on clicking that button sayhello function of script section executes and a alert box appers saying Hello world.

Thank you for visiting this javascript blog if any question or doubts you have you are free to write comment or message me.
Fb:https://fb.com/ythecoder
Youtube: https://www.youtube.com/watch?v=Vj_2I7Csk78

                                           You can watch this youtube video if you like.