Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'overriding' javascript function

I need to add some validations before the user navigates away via an ASP.NET Menu.

I noticed that the items are rendered to use a javascript function called Menu_Key

<td id="ctl00_MainMenun1" onmouseover="Menu_HoverStatic(this)" onmouseout="Menu_Unhover(this)" onkeyup="Menu_Key(this)">

I there a way to override that function and have the menu execute one of mine, from which I could validate what I need and then call the original?

like image 615
juan Avatar asked Apr 22 '26 22:04

juan


1 Answers

Redefine the function after it was initially defined, but keep track of it in a var so that you can call it later. You would effectively be renaming the original Menu_Key function.

var originalMenu_Key = Menu_Key;

Menu_Key = function(t) { 
   // do your validations here

   if ( /* everything validated */ ) {
     originalMenu_Key (t);
   }
};
like image 81
Mario Menger Avatar answered Apr 25 '26 11:04

Mario Menger



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!