Forum Moderators: open

Message Too Old, No Replies

onclick script for buttons not working in mozilla

         

haegens nico

5:00 pm on Jan 13, 2005 (gmt 0)



I use a form with buttons. Each one of them has a name, a value and a onClick event. In IE they work fine, but not in Mozilla and probably neither other browsers. Here is my code:
<script language="javascript1.1" type="text/javascript">
function doAction()
{
var oSource=window.event.srcElement;
var iden=oSource.name;
window.open("/servlet/menus.DBMenuUpdate?dbname=haegens_vva&operation="+iden,"_self");
}
</script>
Here is an example of a button:
<input type="button" name="cmdInvoegen0" value="Invoegen" onClick="doAction()">

tedster

9:46 pm on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello haegens_nico and a very belated welcome to the forums. Sorry your post went so long without an answer in the Browsers Forum.

I think you may have a better chance of finding an answer in the Javascript Forum - so I've moved it over here.

Bernard Marx

10:49 pm on Mar 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Indeed. No probs.

window.event (and the srcElement property) are IE-only.

You don't need to query the event in this case anyway.
Use the keyword, this, in the event handler to send an object reference to the function.

<input type="button" name="cmdInvoegen0" value="Invoegen" onClick="doAction(this)">

function doAction(button) 
{
var iden=button.name;
...as before...