IE6,7,8 this code dose not working
anybody help me.
how can i fix it??
<script type="text/javascript">
function call (event) {
if (document.createEventObject) { // IE before version 9
var mouseclickEvent = document.createEventObject (window.event);
mouseclickEvent.button = 1; // left button is down
document.getElementById("test4").fireEvent ("onclick", mousedownEvent);
}
}
</script>
<body>
<button id="test" onmouseover="call (event);">call</button>
<input id="test3" type="file" onclick="alert(6)"/>
</body>
There're several problems in you code:
event
and window.event
is redundant (and, I'm not sure though, may cause error); test4
. The following code has been tested on IE8 and IE6:
<script>
function call()
{
if(document.createEventObject)
{
var evt=document.createEventObject();
evt.button=1;
document.getElementById("test").fireEvent("onclick",evt);
}
}
</script>
<button type="button" onclick="call();">Fire</button>
<input type="text" id="test" onclick="alert(6);" />
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.