Sorry! The codine must be working. Here's the code:
<html>
<head>
<script type="text/javascript">
function click() {
This creates a property of the global object called 'click'.
var div = document.getElementById("test");
var input = document.getElementById("hidden_input");
div.innerHTML = "changed";
input.value = "changed";
alert(input.value);
}
function doalert() {
alert("alert");
}
</script>
</head>
<body>
<div id="test">id: test</div>
<input type="hidden" name="hidden" value="initial" id="hidden_input"
/>
<a href="#" onclick="doalert(); click();">test</a>
^^^^^^^
The HTML onclick attribute is used to associate script with the 'click'
event. How that happens in IE is different to other browsers.
In IE, if an element has an onclick attribute, it's equivalent DOM
object is given a hidden[1] 'click' property which will mask your click
function that is attached to the global object higher up the scope chain.
In Firefox, the element doesn't have a click property (the event model
is quite different to IE's) so the global click() function runs.