We can write javascript in different ways.
Now we'll see the different methods to write Java script.
Method 1: Writing Java script along with HTML flow.
Just like HTML statements, we can write JS statements also directly in a page and it will be executed in sequenced flow. Only difference is we must indicate to browsers that we are written Java script code. To do that we have:
<script language="javascript">
--------Java script statements----
</script>
Let's see an example to make it clear
Example:
<html>
<head>
<title>Java Script Method 1</title>
</head>
<body>
<h1>Java Script Method 1 demo</h1>
<h1>This is HTML</h1>
<script language="javascript" type="text/javascript">
document.write("This is java Script");
</script>
<h2>Back to HTML</h2>
</body>
</html>
Now we'll see the different methods to write Java script.
Method 1: Writing Java script along with HTML flow.
Just like HTML statements, we can write JS statements also directly in a page and it will be executed in sequenced flow. Only difference is we must indicate to browsers that we are written Java script code. To do that we have:
<script language="javascript">
--------Java script statements----
</script>
Let's see an example to make it clear
Example:
<html>
<head>
<title>Java Script Method 1</title>
</head>
<body>
<h1>Java Script Method 1 demo</h1>
<h1>This is HTML</h1>
<script language="javascript" type="text/javascript">
document.write("This is java Script");
</script>
<h2>Back to HTML</h2>
</body>
</html>
----------------------------------------------------------
** If you like this post please like our page in facebook "Dot Net Support"
0 comments:
Post a Comment