[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Javascript Popup / Ok or Cancel

Posted on 2007-08-03
4
Medium Priority
?
885 Views
Last Modified: 2008-02-20
Hey there guys,

This is a continuation of a previous post: http://www.experts-exchange.com/Programming/Languages/C_Sharp/Q_22736154.html where mplungjan was kind enough o provide me with some JavaScript code to popup a window 1 minute before the application session was about to time out.

I would like some help extending this code some by providing the user with two options.

OK and CANCEL

If the click OK in the popup the users session with be refreshed.

If they click CANCEL in the popup the user will be logged out.

So what I need to know is 1) how to via the popup window to redirect the OK or CANCEL buttons& I have a logout page that if redirected to the user is logged out, and for the OK button I want to refresh the current page the user is on.

Can someone help me with this?

Here is the code I currently have from mplungjan:
-----------------------------------------------------------------------------------------------------------------------
    <script language="javascript" type="text/javascript">
        var timeout = new Date();
        timeout.setMinutes(timeout.getMinutes()+(<%=Session.Timeout%>-1)); // minutes I assume
        var tId = "";
        function check()
        {
          var now = new Date();
         
          if (now>=timeout)
          {
            clearInterval(tId)
            alert('One minute to timeout')
          }
        }
        tId=setInterval('check()',1000); // 1 second
    </script>
-----------------------------------------------------------------------------------------------------------------------

Nugs
0
Comment
Question by:Nugs
  • 3
4 Comments
 
LVL 4

Accepted Solution

by:
pzepernick earned 2000 total points
ID: 19628368
Hello Nugs,

Use the confirm("question here?"); method.  This will return true if they click OK and false if Cancel

if (confirm("question here?")) {
//OK stuff here
} else {
//Cancel stuff here
}

Regards,

pzepernick
0
 
LVL 4

Expert Comment

by:pzepernick
ID: 19628386
Nugs,

Also, use location.reload(true) to refresh and window.location = "logout.html" to redirect


pzepernick
0
 
LVL 2

Author Comment

by:Nugs
ID: 19628591
Ok, that worked great. Just one last question...

I want to add line breaks into my popup text... how do i do that?

like:

TEXT HERE
TEXT HERE...

Nugs
0
 
LVL 4

Expert Comment

by:pzepernick
ID: 19628951
In the String do "text here\ntext here"

Every \n will produce a line break.


Pzepernick
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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)
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

864 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