Html - Space Key Press is Causing OnClick to be Triggered -


[Note: This flaw is only in Internet Explorer 11. It's okay in IE9, Chrome and Firefox.]

I have the following CSS:

  / *** Pop-up devils to cover the whole area * ** / .divModalDialog {status: fixed; Top: 0; Left: 0; Width: 100%; Height: 100%; / *! Important! * / Display: none; / * Final attribute sets dark on scale: 0 ... 1.0 * / background color: RGBA (0,0,0,0.8.8); Text-align: center; Z-index: 101; } / ***! The target attribute does the job! *** / .divModalDialog: Target {Display: Block; }   

one HTML:

  & lt; Div id = "divModalDialogUpdate" class = "divModalDialog" & gt; & Lt; Div & gt; & Lt; Input type = "text" id = "divModalText" /> & Lt; Button onclick = "doStuff ();" & Gt; Press & lt; / Button & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; Div id = "divCanvas" style = "display: none; width: 100%; height: 100%;" & Gt; & Lt; Canvas id = "m_Canvas" width = "200" height = "200" oncontextmenu = "return false;" & Gt; & Lt; / Canvas & gt; & Lt; / Div & gt; As you can see, I am using divModalDialog as a modal dialog box which appears on the canvas dish.  

On the canvas devo, a game is running. When I have to set the modal dialog to fire, I stop the game and then the code is done:

  window.location = "#divModalDialogUpdate";   

The person enters certain items in the text box, clicks the button that triggers the onclick event which runs the function doStuff (). DoStuff () has the following line of code, which is visible only in canvas devilo:

  window.location = "#";   

All this works great.

The problem is now stopped by the game state, and my favorite key is to toggle the breakdown position. (Any other keys and things will get better, but the problem is that I want to use SpaceKey).

That's why I tap the space and triggers an on-click button (unwanted) button. The modal dialog dial again (even if the modal divis is visible now Not giving it) which clearly calls the dot staff () function again.

How do I stop the motion of the model? Whenever the modal div is not visible when the button's onclick event is prevented

Before any argument in the global variable doStuff () , like,

  function doStuff (),  ( Ignore == true) return; / * Logic here ... * /   

Then change your other code like this:

  ignore = false; Window.location = "#divModalDialogUpdate";   

and

  ignore = true; Window.location = "#"; There may be a way to do this by using   

event.stopPropagation () but I could not find any way to make that work.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -