Solved

auto close confirmation dialog

Posted on 2008-06-22
6
3,530 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
  • 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 500 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn how to dynamically set the form action using jQuery.

707 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now