Forum Moderators: open

Message Too Old, No Replies

calling onclick function

         

adaptor40

6:39 am on Oct 16, 2008 (gmt 0)

10+ Year Member



hello

i have a DIV which contains a onclick function..in IE i just call objDiv.click() and the function is executed.
But with Firefox 3.0.3..this does not work

any suggestion? ....here a sample
function get()
{
alert("clicked");
}
function calldivfunction()
{
mydiv.click();
}
<DIV id=mydiv onclick="get()">DIVDATA</div>
<INPUT TYPE="button" VALUE="CLICK" ONCLICK="calldivfunction()">

u click the button...the div function is executed in IE but FF fails.... :(

Thanks

daveVk

10:36 am on Oct 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



function calldivfunction()
{
var el = document.getElementById("mydiv");
if ( el.click ) { el.click(); )
else {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
el.dispatchEvent(evt);
}
}