Javascript – How to stop further JavaScript events from executing


I'm using an Infragistics grid on a form and am handling multiple client-side events on the cells (e.g. cell click, before cell edit, before cell update, etc).

On the cell click event, I'm spawning a secondary window (successfully) as follows:

 var convChartWindow ="conversioncharts/" + currentCell.getValue() + ".html", "chart", "location=0,0, status=1, scrollbars=1, width=" + screen.width + ", height=175");        

However, the 'convChartWindow' does not maintain the focus, and gets covered with the parent window. None of my other cell events fire after this, but there seems to be some Infragistics JavaScript that runs.

Is there a something I can put after the .focus() above to prevent further javascript from running and keep the focus on the correct window?


Best Solution

Call this:

// Prevents event bubble up or any usage after this is called.
// pE - event object
function StopEvent(pE)
   if (!pE)
     if (window.event)
       pE = window.event;
  if (pE.cancelBubble != null)
     pE.cancelBubble = true;
  if (pE.stopPropagation)
  if (pE.preventDefault)
  if (window.event)
     pE.returnValue = false;
  if (pE.cancel != null)
     pE.cancel = true;
}  // StopEvent

This was snipped from here: What is equivalent of 'event.returnValue=false' in Firefox

and was written by Peter Blum