Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    problem with confirm() in internet explorer

    Hi

    I am using confirm() message box in java servlets, i am geting problem with popup blocker even i enable the popup blocker.

    please guide me to solve this problem.


    Thank you.

    Regards
    Surendra

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    3,772
    Thanks
    23
    Thanked 550 Times in 549 Posts
    1. When talking IE it is best to give ver number as they all work differently. I check the below code in IE8 and it works for me.
    2. We are in the dark and have to guess if code is not supplied.
    3. java servlets is for a different language, java not javascript.

    What I check:
    Code:
    <!DOCTYPE html>
    <html>
    <body>
    <p>Click the button to display a confirm box.</p>
    <button onclick="myFunction()">Try it</button>
    <p id="demo"></p>
    <script>
    function myFunction()
    {
    var x;
    var r=confirm("Press a button!");
    if (r==true)
      {
      x="You pressed OK!";
      }
    else
      {
      x="You pressed Cancel!";
      }
    document.getElementById("demo").innerHTML=x;
    }
    </script>
    </body>
    </html>
    4. Such things as confirm boxes, prompt boxes, and alert boxes are not used much in programming anymore except for testing purposes.

  • #3
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,479
    Thanks
    0
    Thanked 635 Times in 625 Posts
    confirm() is for debugging use only and is rarely needed even then so it doesn't really matter whether it works or not - it could be deleted from JavaScript now without having any real impact.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    As the original poster said, he is getting the problem in JAVA servlets. Not JavaScript. So he is posting in the wrong forum.

    I would assume, since he says the JAVA confirm() is being blocked by the popup blocker, that the JAVA confirm is, indeed, using a popup window and has nothing to do with JavaScript's window.confirm( ) method.

    See, for example, the various kinds of confirm dialogs noted here:
    http://docs.oracle.com/javase/tutori...ts/dialog.html
    Last edited by Old Pedant; 01-02-2013 at 08:26 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New to the CF scene
    Join Date
    Jan 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi

    thanks for the reply.

    but i am unable to understand my prooblem...
    please check the below to codes which i am using in two diffrent programs

    1) first code is working on same IE

    out.println("function popMessage(f)");
    out.println("{");
    out.println("if(f.chk.checked) ");
    out.println(" if(confirm('If you click the Post button now the agreement will be removed from Action List '))");
    out.println(" { }");
    out.println("else");
    out.println("{f.chk.checked=false");
    out.println(" }");
    out.println("}");

    2) Second code is the problem code with popup blocker on IE

    out.println(" if( info == '--') ");
    out.println(" {");
    out.println(" var x= confirm('Für diese Aktion wurden bereits Kosten verbucht. Sind Sie sicher, dass Sie weitere Kosten verbuchen wollen?”');");
    out.println("if (x)");
    out.println(" {");
    out.println("window.open('Costreason.html', '', 'height=350,width=450');");
    out.println("window.close();");
    out.println(" }");

  • #6
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,734
    Thanks
    202
    Thanked 2,508 Times in 2,486 Posts
    As has been pointed out, this is JAVA code so you have posted in the wrong forum. This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names. Rather like Austria and Australia! Ask a mod to move this thread to the right forum.

    But it is obvious that the problem lies with the literary quotes in

    Kosten verbuchen wollen?”');");

    That will barf in any browser, not just IE.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Ummm...Philip, although he is using Java to *write* the output, that's just server-side Java.

    That server-side Java *IS* creating JavaScript, correctly.

    Specifically, the second set of Java code is producing *this* client-side JavaScript for the browser:
    Code:
    if( info == '--') 
    {
        var x = confirm('Für diese Aktion wurden bereits Kosten verbucht. Sind Sie sicher, dass Sie weitere Kosten verbuchen wollen?”');
        if ( x ) 
        {
            window.open('Costreason.html', '', 'height=350,width=450');
            window.close();
        }
    }
    It is true that he has a bogus "literary quote" mark in there, as shown in the large red text, but that won't hurt anything as it will be ignored by JavaScript (and Java, incidentally) and only the subsequent apostrophe will be used, correctly.

    As shown, the code is missing one closing right brace } as I have indicated, but since he says the code works in browsers other than IE, it's probably really there in the actual code.

    I really think he may be right, that his is a problem with a popup blocker.

    ********

    On the other hand, the code also doesn't make tons of sense.

    He opens the popup window for 'Costreason.html' but then *CLOSES* the CURRENT WINDOW. Why? If you only want one window to remain open, just *replace* the current window with the new one.
    Last edited by Old Pedant; 01-03-2013 at 08:47 PM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •