Clicking OK in a prompt - javascript

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.

Related

How to bind an event in a Facebook Like Button

first of all, sorry for my bad english.
I would like to create a "like-close" button for my site. Now I'll explain what I mean.
I've created 2 div, 1 for an overlay background in all the browser window and one for a window where I ask users to "Like" my facebook page.
I have also created a close button for hide the 2 divs and in this button I have hidden another Facebook Like Button and, when a user try to close the popup, he will put a "Like". In this button I wrote "close and like" so, for who thinks It's a clickjacking, the users know what they are doing.
I've been able to close the window in the same moment when the user click on the button on the first time (so, before he didn't like my page) with the method
FB.Event.subscribe('edge.create', function(response) {
jQuery('#overlay').hide(); //hide the overlay
jQuery('#popoup').hide(); //hide the popup window
});
Now when he visit my page again, the popup will appear again and I don't know how to close it without "dislike" the page.
I tried to bind an event "click" in the iframe of like button but it didn't work.
I tried to bind an event in the wrapper of the iframe but it didn't work...
So I have no more ideas and I know it's possibile because I saw this trick in another web site.
Thank you all for help
Sorry, in the button where I hide the Facebook like I wrote "like and close". It's the only button in the Window for show the main page content just to fans.

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.

Having difficulty closing a PopUP window, after update and submit button

So, I have a javaScript that calls an ASP page, using ShowModalDialog ... it works great, passes the correct information, the user is then prompted with radio button to answer a question, then if the user presses "submit" ... the data is written to a SQL table. this all works; however, I cannot get the window to close. The behavior is the program opens another page (same content as in the window popUP) only it is full page size.
When I tried to add the following code: Response.Write("script language='javascript'?window.close();") ... I get the same behavior with a message indicating that the program is trying to close the window.
this is so frustrating because I don't understand why closing a window is so diffcult.
Please help if you can.

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()

I need to keep the modal from being closed by the user

Any Ideas?
I tried inserting ....({ .....,...., close:false,....}) and nothing.
Thanks in advance.
PS: I will close the modal window when satisfied with $.modal.close();
If you call a modal window as you have indicated {close:false}, the following will happen:
The closeHTML will not be displayed
The user cannot click the overlay to close the dialog
The user cannot press ESC to close the dialog
If you have a button/link in your code with the simplemodal-close class, the user will still be able to press that to close the dialog.
So, based on the information you have provided, if you are using {close:false}, the only other way possible for a user to close the dialog is if you have provided a way for them to. As such, you need to hide, disable, or remove the simplemodal-close class until you are ready for them to close the dialog.

Categories

Resources