Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

auto close confirmation dialog

Posted on 2008-06-22
6
Medium Priority
?
3,633 Views
Last Modified: 2013-11-19
Hi,
I have a confirmation dialog. It is being used to warn the user about a time consuming operation, and confirm that he wants to proceed. The problem is that the dialog window does not close until all the JavaScript on the page stopped executing.

How is it possible to close the dialog window or set a time limit, etc.?

function verify()
{
  var result= confirm("This operation may take up to one minute. Do you want to proceed?");
  if (!result)
  {
    exit();
  }
  
}
//The dialog window is not closed after the function finishes executing. //It is closed only after all javascript on the page stops running.

Open in new window

0
Comment
Question by:msosno
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
6 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 21843635
Check this:


function verify(){
  if(confirm("This operation may take up to one minute. Do you want to proceed?")){
     setTimeout("doTheComputation()", 10);
  } else {
     setTimeout("exit()", 10);
  }
}
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 2000 total points
ID: 21843643
I do not know your exit() function but perhaps it does not work globaly.
Then check this:

function verify(){
  if(confirm("This operation may take up to one minute. Do you want to proceed?")){
     setTimeout("doTheComputation()", 10);
  } else {
     exit();
  }
}
0
 
LVL 16

Expert Comment

by:Lolly-Ink
ID: 21851373
You can't use the JavaScript confirm method for this. The confirm method stops JavaScript from executing. You'll have to use a floating div element with content to simulate a dialog box. Examples can be found by performing an internet search with tags: JavaScript close alert OR confirm.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:msosno
ID: 21851807
Zvonko: Thanks, everything works.
Is there a way to end script execution?
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21852984
No, there is not. You can only exit the current function with the return statement. In the return statetement you can pass a return value. Depending on that return value can the calling function do a return exit to the next calling level. But you canot kill the parent calling function execution levels.
http://home.cogeco.ca/~ve3ll/jstutor3.htm
0
 
LVL 63

Expert Comment

by:Zvonko
ID: 21852987
Or short: use return statement to exit the function execution.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

636 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question