Sunday, 15 July 2012
<!DOCTYPE html>
<html>
<body>
<h1>Web Page</h1>
<p id="demo">A Paragraph.</p>
<button type="button" onclick="myFunction()">Try it</button>
<p><strong>Note:</strong> The actual script is in an external script file called "myScript.js".</p>
<script type="text/javascript" src="myScript.js"></script>
</body>
</html>
Result:
Web Page
My First External JavaScript
Sunday, 15 July 2012 by Unknown · 0
<!DOCTYPE html>
<html>
<body>
<h1>Web Page</h1>
<p id="demo">A Paragraph.</p>
<script type="text/javascript">
document.getElementById("demo").innerHTML="My First JavaScript";
</script>
</body>
</html>
Result:
Web Page
My First JavaScript
by Unknown · 0
<!DOCTYPE html>
<html>
<body>
<h1>My Web Page</h1>
<script type="text/javascript">
document.write("<p>First JavaScript</p>");
</script>
</body>
</html>
Result:
My Web Page
First JavaScript
by Unknown · 0
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
function person(firstname,lastname,age,eyecolor)
{
this.firstname=firstname;
this.lastname=lastname;
this.age=age;
this.eyecolor=eyecolor;
}
myFather=new person("Peter","park",20,"black");
document.write(myFather.firstname + " is " + myFather.age + " years old.");
</script>
</body>
</html>
The result is:
Peter is 20 years old.
by Unknown · 0
<!DOCTYPE html>
<html>
<body>
<script type="text/javascript">
personObj={firstname:"peter",lastname:"park",age:20,eyecolor:"black"}
document.write(personObj.firstname + " is " + personObj.age + " years old.");
</script>
</body>
</html>
The result is:
Peter is 20 years old.
by Unknown · 0
Subscribe to:
Posts (Atom)