Monday, 2 January 2012

creating a new window

creating a new window

smallwin = window.open("","small", "width=100, height=120, toolbar=0, status=0");
                                       url, windows name, feature list

Time Out

ident=window.setTimeout("alert('Time is up!')", 10000);

onmousedown event

<html>
<head>

<title> creating an event handeler </title>

<script type="text/javascript">

    function mousealert() {
    alert ("You clicked the mouse");
    }
    document.onmousedown = mousealert;
   

</script>

</head>

<body>

</body>

</html>

onMouseOver event

<html>
<head>

<title> creating an event handeler </title>



</head>

<body>

    <a href="http://www.westerntowncollege.com" onMouseOver="window.alert('you moved over the link.');">
    Click here</a>
   


</body>

</html>

chapter 11 creating custiom object

<html>
<head>

<title> Javascript business card </title>

<script type ="text/javascript">

    function PrintCard (){
    line1 = "<b>Name: </b>" + this.name + "<br />\n";
    line2 = "<b>Address: </b>" + this.Address + "<br />\n";
    line3 = "<b>Work Phone: </b>" + this.workphone + "<br />\n";
    line4 = "<b>Home Phone: </b>" + this.homephone + "<hr />\n";
    document.write(line1, line2, line3, line4);
    }
   
    function Card (name, address, work, home){
    this.name = name;
    this.address = address;
    this.work_phone = work;
    this.home_phone = home;
    this.PrintCard = PrintCard;
    }
</script>

</head>

<body>

<h1>Javascript Business Card Test </h1>
Script begins here.
<hr />

<script type ="text/javascript">

    sue = new Card("Sue suthers", "123 Elm street", "555-1234", "555-9876");
    phred = new Card("Phred Madsen", "233 Oak Lane", "555-2222", "555-4444");
    henry = new Card("Henry Tillman", "233 Walnut Circle", "555-1299", "555-1344");
   
    sue.PrintCard();
    phred.PrintCard();
    henry.PrintCard();
   
</script>
    End of script.

</body>

</html>


-----------------------------------------------------------------------------------
output

Javascript Business Card Test

Script begins here.
Name: Sue suthers
Address: undefined
Work Phone: undefined
Home Phone: undefined
Name: Phred Madsen
Address: undefined
Work Phone: undefined
Home Phone: undefined
Name: Henry Tillman
Address: undefined
Work Phone: undefined
Home Phone: undefined
End of script.