lots_of_questions
lots_of_questions

Reputation: 1149

Javascript Chrome confirm box delay

When displaying a confirm box in javascript, there seems to be a delay after clicking Yes or No when the Yes or No causes a page redirect. The delay is about the duration of how long the confirm box is open for. This only happens in Chrome for me. Does anyone have a solution to make this so there is no delay in Chrome?

A simple example depicting the problem:

<html>
    <head></head>
    <body>
        <script type='text/javascript'>
            var goToGoogle = confirm("Go to Google?");
            if (goToGoogle) {
                window.location.href="http://www.google.com";
            }
        </script>
    </body>
</html>

Thanks for your help!

Upvotes: 6

Views: 1988

Answers (1)

Drew Gaynor
Drew Gaynor

Reputation: 8472

This seems to be Issue 98275: Javascript confirm dialog creates long delay and appears to lock up page. It is marked as fixed, though it seems users are still seeing it based on the comments. I can confirm the bug is present in 18.0.1025.142.

As for a solution for users with versions of Chrome without this bug fix, I've created a basic implementation of a modal dialog you can use in this jsFiddle. It is based on this article: Create a Modal Dialog Using CSS and Javascript.

Alternatively, if you are using/plan to use jQuery, you could use jQuery dialogs.

Upvotes: 4

Related Questions