Javascript - Closing confirmation message if no response from user - javascript

I have got asp.net 2.0 website, in which I display session timeout through confirm message box, asking user to select ok or cancel.
Problem: if user doesn't provide any input (assuming his desktop is locked and he is out for lunch) - then how can I close this confirmation message and display another pop-up or re-driect to login page
Regards

If you are using the native browser confirmation box you cannot dismiss that, the user would need to do so. If you create your own, then you can use setTimeout to dismiss after a certain amount of time

As haslama suggested that you will have to create a custom alert as you can't dismiss the browser confirmation box.
As an alternative you can show a div based message to user instead of an alert, and in that div user can select OK or cancel and you can implement timeout for that div.

Related

Browser Tab Close Event for javascript or jquery

I have added a div which contains some survey questions which is initially hidden. Once the user closes the window or navigate away from the page, I need to popup the survey div to get the confirmation. I know there is a browser default confirm box method by using onbeforeunload event. But I need to popup the div rather than the browser default confirm box. Is there any way to do this? (or is there any way to interrupt the close event without even clicks on the "Stay on page" button found in the browser default confirm box?)
UPDATE : it seems we cannot do the action you are asking. There are some solutions to cover this in IE but overall its not possible. Ignore all the previous code.

How facebook/twitter share buttons avoid being blocked by popup blockers?

When a user which is not logged in to Facebook or Twitter, clicks the like/tweet button, a popup comes up asking the user to log in. This popup is not blocked by popup blockers of any kind. in IE for example, it opens up but anyway IE state a warning to the user. The bottom line is that all buttons probably use the same method.
I have a button that people click on it and it should open a similar screen, but it always gets blocked.
The button (in JS) works pretty much like FB like button. It checks if the user is logged in. If he does, then send the "like" to the servers. If he does not, then the login popup appears (and gets blocked).
So, it is a initiated by a user although not fully direct outcome, since we need to check if he logged in or not.
What is best method to do that?
The Popup Is activated by a click using the like, tweet button and they actually show only 1 popup. If you want, you can try by using only a single popup based on click for your website and you will definitely be able to understand this.

Clicking OK in a prompt

I know how to create alerts and confirm boxes, but what I cannot find out how to do is to do the actual clicking of OK. I have a page that pops up a confirm box. I want to click OK using a Java Script add-on. Basically, I want my code to click a link on the page, then click ok when prompted. Is that possible?
That's not possible with a browser pop-up.
However if it's a modal dialog that sits within the DOM of the page, then you can trigger a JavaScript event to close it. An example of such a dialog is jQuery's dialog.

Javascript to close browser window simultaneously with dialog box

I'm working on an asp.net web form. This form has a button to open a new window (report window) and show a report. But first the user has to select a client from the list in the form before he/she can see the report. For validation matter, I use code to check whether the user has selected one of the client or not, the validation is done in the new window (report window).
The validation is set to show a javascript dialog box if the user hasn't selected one of the client, it's working fine, the dialog box show the message with a single OK button. Is it possible to close the window concurrent with the dialog box when the user click the OK button ?
Not with an alert window (you cannot get the event when the user clicks ok), you need either
a confirm instead of an alert so you can react on the event
or a "self-made" dialog like jquery dialog http://jqueryui.com/demos/dialog/ there you can react on the click event
And then just close the window with window.close()

Check if User has clicked "Ok" for "onbeforeunload event"

I am checking when the user closes the browser window, if he says ok, how i do I trigger some action, like opening another window or saving a form. If he chooses "cancel", it should stay in the same page (which is working now). pls share some idea on how to approach this issue
Sample Code
You cannot react to the user clicking on the "Leave this page" button. This is by design of the browser: if the user wants to leave, let him go.
If the user chooses to cancel, you can try a technique found in this answer to similar question to execute some custom code like saving changes or the like.

Categories

Resources