Peter76
March 14th, 2011, 04:34 PM
I have the following html:
<!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" xml:lang="en" lang="en">
<head>
<title>Click Test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="content-style-type" content="text/css"/>
<script src="clicktest.js" type="text/javascript"></script>
</head>
<body>
<div id="clicktst">Hello World</div>
</body>
</html>
And the following javscript file:
window.onload = function() {
var maskDiv = document.getElementById( "clicktst" );
if ( maskDiv ){
maskDiv.style.cursor = "pointer";
maskDiv.onclick = alert( "ok" );
}
}
The problem is that when I open the html in FF, a popup shows with ok, but when I click on the div nothing happens, though the mouse arrow is correctly set to pointer.
What am I doing wrong here, guess it's something very obvious, but I can't find what.
Thanks, Peter
<!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" xml:lang="en" lang="en">
<head>
<title>Click Test</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<meta http-equiv="content-style-type" content="text/css"/>
<script src="clicktest.js" type="text/javascript"></script>
</head>
<body>
<div id="clicktst">Hello World</div>
</body>
</html>
And the following javscript file:
window.onload = function() {
var maskDiv = document.getElementById( "clicktst" );
if ( maskDiv ){
maskDiv.style.cursor = "pointer";
maskDiv.onclick = alert( "ok" );
}
}
The problem is that when I open the html in FF, a popup shows with ok, but when I click on the div nothing happens, though the mouse arrow is correctly set to pointer.
What am I doing wrong here, guess it's something very obvious, but I can't find what.
Thanks, Peter