Solved

auto close confirmation dialog

Posted on 2008-06-22
6
3,597 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 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
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

690 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