asp.net - How to stop further JavaScript events from executing - Stack Overflow

I'm using an Infragistics grid on a form and am handling multiple client-side events on the cells

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 = window.open("conversioncharts/" + currentCell.getValue() + ".html", "chart", "location=0,0, status=1, scrollbars=1, width=" + screen.width + ", height=175");        
convChartWindow.focus();

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?

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 = window.open("conversioncharts/" + currentCell.getValue() + ".html", "chart", "location=0,0, status=1, scrollbars=1, width=" + screen.width + ", height=175");        
convChartWindow.focus();

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?

Share Improve this question edited Feb 14, 2022 at 14:01 Brian Tompsett - 汤莱恩 5,89372 gold badges61 silver badges133 bronze badges asked Feb 12, 2009 at 20:02 Chris BurgessChris Burgess 5,83513 gold badges57 silver badges69 bronze badges
Add a ment  | 

4 Answers 4

Reset to default 4

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;
     else
       return;
  if (pE.cancelBubble != null)
     pE.cancelBubble = true;
  if (pE.stopPropagation)
     pE.stopPropagation();
  if (pE.preventDefault)
     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
See: PeterBlum.

i dont know what infragistics is. ill assume its some framework over which you have no control. if i were you i would try the following:

1) set a timeout to take focus back to the window after 1000 ms, or set a timeout loop to set focus to the window you need. this is a hack.

2) figure out what functions fire the events that ruin your life, override those functions in your code and add a flag that will prevent them from doing something evil

3) last, atleast read this: http://www.quirksmode/js/events_order.html there might be something useful for you in there

Have the child window call the focus itself when it opens.

If there is something else in the function that runs the code you gave, try using:

break;

after:

convChartWindow.focus();

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744254540a4565331.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信