PDA

View Full Version : Javascript Problem - Changing Event



SaveFerris
04-08-2007, 05:56 PM
I'm having problems changing the event of some elements. This following code works perfectly fine in Firefox:

workin.attributes["onmouseover"].value = b2use+"(this.id)"
workin.attributes["onclick"].value = b2use+"2(this.id)"
But it doesn't work in IE, can someone help me with changing the event for IE?
Thank you.

PS. Anyone who is going to say use workin.onclick, don't bother. It doesn't work with functions that require parameters.

tesco
04-09-2007, 01:17 AM
I thought about it for a while and maybe you could make it call a function with no paramater using workin.onclick and that function that is called will then call another function WITH parameter?

An example:


<script type="text/javascript">
<!--
document.getElementById('whatever').onclick = "var param='whatever';newfunction();";

function newfunction()
{
return therealfunctionwithaparam(param);
}

function therealfunctionwithaparam(param)
{
dowhateverhere();
return param;
}
//-->
</script>

SaveFerris
04-09-2007, 02:07 AM
Wow, that makes sense. Thanks Rossco, I'll edit/repost once I've tried.

Nope, didn't work. :(