39 lines
950 B
HTML
Executable File
39 lines
950 B
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<title>Example 5.23</title>
|
|
<script>
|
|
function getSwap()
|
|
{
|
|
var again = "y";
|
|
var pic = "troll";
|
|
while (again == "y")
|
|
{
|
|
if (pic == "wizard")
|
|
{
|
|
document.getElementById('photo').innerHTML = "<img src = 'troll.jpg' />";
|
|
pic = "troll";
|
|
var again = prompt("See new image? y/n?", " ");
|
|
}
|
|
if (pic == "troll")
|
|
{
|
|
document.getElementById('photo').innerHTML = "<img src = 'wizard.jpg' />";
|
|
pic = "wizard";
|
|
var again = prompt("See new image? y/n?", " ");
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<table align ="center" width ="70%"><tr><td colspan ="2">
|
|
<h1> </h2>
|
|
<h1>Swapping Images</h1>
|
|
<p><input type="button" id="swap" value="Push me to change the image" onclick="getSwap();" /></p>
|
|
<table align="center" width = "70%"><tr><td id = "photo" name = "photo">
|
|
<img src = "troll.jpg" alt = "troll" name = "myPhoto" />
|
|
</td></tr>
|
|
</table></body>
|
|
</html>
|
|
|