JavaScript Examples           

Instructor: Amadou O. Wane

Windows Objects
<html>
<head>
<script language="javascript">
function openwindow()
{ //window1=window.open("http://www.cnn.com", "my_new_window","toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,
resizable=no,width=500, height=400")
//window2=window.open("http://www.abc.com")
window.status="put any message here";
location = "http://www.abc.com";
}
</script>
</head>

<body>
<h3> WINDOWS OBJECTS</h3>
<script language="javascript">
//ALERT BOX
//alert("Hello world">;
var name = confirm("Press a button");
if (name == true)
{ document.write("You pressed OK");
}
else
{ document.write("You pressed cancel")
}
</script>
<form>
<input type=button value="Open Window" onclick="openwindow()">
</form>
<html>

<body>
<table width=500 height=400 border=1>
<tr> 
<td>hello</td>
</tr>
<tr>
</tr>
<td>row2</td>
<tr>
<td>row3</td>
</tr>
</table>
</body>
</html>
</body>
</html>



Cascading Style Sheet

Example1:
<HTML>
<HEAD>
<TITLE>HTML Selector</TITLE>
<STYLE TYPE="text/css">

{
font: bold 16pt times,serif;
text-decoration: underline;
}

</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
Here is an example of how to make bold <B>really</B> bold.
</BODY>
</HTML>


Example2:
<HTML>
<HEAD>
<TITLE>CSS Classes</TITLE>
<STYLE TYPE="text/css">
B.extra {font-style: italic; font-size: 18pt;}
.huge {font-size: 42pt;}
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
Look, this is <B>really</B>, <B class="extra">really</B>, <BIG class="huge">really</BIG> important.
</BODY>
</HTML>


Example3:
<HTML>
<HEAD><TITLE>Font Size</TITLE>
<STYLE TYPE="text/css">
BODY {font-size: 12pt;}
H3 {font-size: larger;}
</STYLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<H3>CHAPTER II<BR>The Pool of Tears</H3>
<P>'Curiouser and curiouser!' cried Alice (she was so much surprised,
that for the moment she quite forgot how to speak good English);
'now I'm opening out like the largest telescope that ever was!
And how odd the directions
will look!</P>
</BODY>
</HTML>