The HTML form shows but the javascript callback is not executing.
(and how do I combine into one file?)
thx
<html>
<head>
<title> Mouse click test</title>
</head>
<body>
<h1>Mouse Click Test</h1>
<p>Click the mouse on the test link below. A message below will indicate which button was clicked.</p>
<h2><a href = "#" id = "testlink">Test Link</a></h2>
<form name = "form1">
<textarea rows = "10" cols = "70" name = "info"></textarea>
</form>
<script type = "text/javascript" scr = "click.js">
</script>
</body>
</html>
function mousestatus(e){
document.write("hello");
if (!e) e = window.event;
btn = e.button;
whichone = (btn < 2) ? "Left" : "Right";
message = e.type + " : " + whichone + "\n";
document.form1.info.value += message;
}
obj = document.getElementById("testlink");
obj.onmousedown = mousestatus;
obj.onmouseup = mousestatus;
obj.onclick = mousestatus;
obj.ondblclick = mousestatus;
The attribute for the
<script>tag issrc, notscr. This:Should be:
And get rid of the
document.writecall,document.writewill:And
document.open:So calling
document.writeanywhere except inside an inline<script>will erase everything before inserting your new stuff; about the only time you should usedocument.writeis in things like this:You’d usually use
console.log('...')orconsole.debug('...')for quick debug messages (assuming that you’re using a browser with a console and you have the console open).Once you take care of those issues, you should have something that does more interesting things than throw errors (or nothing at all): http://jsfiddle.net/ambiguous/5kHVy/
You might want to read up the newer event handling interfaces (such as
addEventListener).