I wrote a simple code that should re-size the image (there's some other code in here just in case):
var userName,
imageHeight = document.getElementById("rock").style.height;
function resizeRock() {
imageHeight = (document.body.clientHeight - 100) * 0.9;
}
function greetUser() {
alert("Hello, I am your pet rock.");
}
function touchRock() {
userName = prompt("What is your name?", "Enter your name here.");
if (userName) {
document.getElementById("rock").src = "rock_happy.png";
alert("It is good to meet you, " + userName + ".");
}
setTimeout("document.getElementById('rock').src='rock.png';", 20000);
}
My problem is that it doesn't work. Image always stays the same. Any tips how I can fix this?
P. S. Here's the HTML code also (if it helps):
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Irock nesto</title>
<link type="text/css" rel="stylesheet" href="generic.css" />
<script type="text/javascript" src="jsSkripta.js"></script>
</head>
<body onload="resizeRock(); greetUser();">
<div id="slika">
<img id="rock" src="rock.png" alt="iRock" style="cursor:pointer" onclick="touchRock();" />
</div>
</body>
</html>

New Topic/Question
Reply



MultiQuote



|