August 20, 2009

Javascript 17: Objects

Start off with an HTML script

<html>
<head>
<script type=""text/javascript">
function book(harrypotter,lordflies,chocolatewar)
{
this.harrypotter=harrypotter;
this.lordflies=lordflies;
this.chocolatewar=chocolatewar;
}

var book= new book ("harry potter","sowhead","trinityschool");
</script>
</head>

<body>

<script type=""text/javascript">
document.write("the book that i like the most is "+book.harrypotter);
</script>


</body>
</html>

This is going to display a text string with the sentence "the book that I like the most is " and then harry potter because that is what I defined with the variable.



, , ,



Powered by ScribeFire.

No comments:

Post a Comment