custom alert box that pauses program until button is pressed

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rod Jackson
    New Member
    • Dec 2010
    • 2

    custom alert box that pauses program until button is pressed

    I have written a program in javascript and it works as I want it too. However it uses the "alert" command at various points. I wanted to make a custom alert so I googled that and all the result make nice looking alert boxes, however there is a fatal problem when I use them rather than the normal javascript "alert" command. The custom alerts never stop the program at that point until the user shuts it down by clicking on the "ok" button. My current code can be seen at -

    http://www.shogiwar.we bs.com/Gunnm_Paraphern alia/Chinchirorin.ht ml

    (click on "view source" in your browser to see the code). click on the "roll dice" for the alert buttons to appear. (you'll see in my code I've commented out the custom alert stuff).

    How do I create a custom alert box that also stops the program at that point until the user clicks the "ok" button (or whatever button I create in my custom alert box)?

    thanks in advance,
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Put an overlay over the whole page, e.g. see this example.

    Comment

    • Rod Jackson
      New Member
      • Dec 2010
      • 2

      #3
      Sorry I obviously wasn't clear about what the problem is. I tried the code in this link but it doesn't work, that is, it doesn't solve my problem. This link seems to be dealing with the issue of people clicking on other parts of the screen while the alert box is showing. This is not my problem. consider the following code -
      Code:
        for (i=0; i<4; i++)
        {
          alert("i="+i);
        }
      in using a "normal" alert then each iteration though this loop there will be an alert box appearing with the text "i=0", "i=1" etc. However if I use the modified alert box then there will not be an alert box for each iteration of the loop. Only one alert box will appear with the text "i=4". How do I get the custom alert box to stop the program from continuing so that each iteration of the loop will work?

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Ah, I see. You're going to have to program this functionality in yourself. So, when calling a custom alert, change it to call the next line on clicking OK.

        I've never done this myself, so I'll just explain the theory and hopefully it should work in practice, but I've not tested. In the case of your for example, you could perhaps change the code to gather the expected alert outputs and then pass the next one to the alert function to execute once the current one is "complete", i.e. when the user clicks OK.

        Hope that makes sense. This is probably just one way you could solve it.

        Comment

        • rnd me
          Recognized Expert Contributor
          • Jun 2007
          • 427

          #5
          use showModalDialog
          see http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx
          and https://developer.mozilla.org/en/DOM...howModalDialog

          Comment

          Working...