Instructor: Amadou O. Wane
Last update: 10/25/01
Lecture8:Windows Objects & Tables
Alert Box
<html>
<body>
<script type="text/javascript">
alert("Hello World!")
</script>
</body>
</html>
//--------------------------------------------------------
Confirm Box
<html>
<body>
<script type="text/javascript">
var name = confirm("Press a button")
if (name == true)
{
document.write("You pressed OK")
}
else
{
document.write("You pressed Cancel")
}
</script>
</body>
</html>
//--------------------------------------------------------
Prompt Box
<html>
<head>
</head>
<body>
<script type="text/javascript">
var name = prompt("Please enter your name","")
if (name != null && name != "")
{
document.write("Hello " + name)
}
</script>
</body>
</html>
//--------------------------------------------------------
New Window
<html>
<head>
<script language=javascript>
function openwindow()
{
window.open("http://www.intechs.net")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Window" onclick="openwindow()">
</form>
</body>
</html>
//--------------------------------------------------------
Customize New Window
<html>
<head>
<script type="text/javascript">
function openwindow()
{
window.open("http://www.cnn.com","my_new_window","toolbar=yes,
location=yes,status=no,menubar=yes,scrollbars=yes,
resizable=no,copyhistory=yes,width=400,height=400")
}
</script>
</head>
<body>
<form>
<input type="button"
value="Open Window"
onclick="openwindow()">
</form>
</body>
</html>
//--------------------------------------------------------
Multiple Windows
<html>
<head>
<script language=javascript>
function openwindow()
{
window1=window.open("http://www.microsoft.com/")
window2=window.open("http://www.cnn.com/")
}
</script>
</head>
<body>
<form>
<input type=button value="Open Windows" onclick="openwindow()">
</form>
</body>
</html>
//--------------------------------------------------------
Browser Location
<html>
<head>
<script type="text/javascript">
function locate()
{
location="http://www.w3schools.com/"
}
</script>
</head>
<body>
<form>
<input type="button" onclick="locate()" value="New location">
</form>
</body>
</html>
//--------------------------------------------------------
Status Bar
<html>
<head>
<script type="text/javascript">
function load()
{
window.status = "put your message here"
}
</script>
</head>
<body onload="load()">
<p>Look in the statusbar</p>
</body>
</html>
|