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.
Related
I want to make popup which freezes the browser until the popup is closed. But I am stuck at a point since on closing the browser, it is asking the user to stay or leave but when a user clicks on leave it shuts down. I instead want a that when a user clicks the leave option it either reload the site or do nothing, also on doing the same for second time Chrome is giving alert to prevent any additional dialogue which I want to disable or it should do nothing. Until the popup is closed. So at last users should not be able to close their browser from a closing button of browser or by going back or replacing the URL. It should freeze until the requirement of the popup is fulfilled. Thank you and please help.
You can't force the users to stay on your site as the browser doesn't allow this (think of a malicious site forcing you to stay there). Your approach is probably the best you can do. Show a dialog that says something like. "Please wait while exiting..." or similar.
If you want to hide the "Block additional dialogs from this page" thing you can create your own dialog. Just a div with position: fixed and display: none and then onBeforeUnload show it with display: block.
Here is more on that: Stackoverflow.com
In that case you can use bootstrap popup:
like this:
https://www.w3schools.com/bootstrap/tryit.asp?filename=trybs_modal&stacked=h
and on the click event on close button you can add new alert or some other popup..
and closing this type of popup box cannot reflect other data..
It might helps you.!
I am opening a popup after main window load.
Problem:
When user actually click on link the popup opens without complaining anything.
But when I am using Javascript call to click on href, I am getting popup blocker.
I am suspecting that, browser identifies that, popup is opening without any actual operation by user and that's why it is blocking popup.
In herf, I am calling a javascript method to open the popup.
I searched all the questions regarding opening popup and simulating the click like this, these works fine to simulate the click but still getting popup blocker.
Is there any workaround to fool browser?
You can't fool the browser per-se in this scenario. You could however, launch a div as an overlay on the main window if that's an option.
After several time showing alert window the browser ask whether to prevent creating additional dialog.
Is there a way to force JavaScript show alert window even the user has checked the 'Prevent this page from creating additional dialog' ?
No, there isn't.
Thank goodness.
(you could, however, fake it with a modal dialog--possibly jQuery UI would suit your needs)
The whole point of that checkbox is to prevent sites from continuously spamming the user with alert boxes, preventing them from accessing anything in their browser anymore, even switching tabs. If it were possible for a site to continue posting new alert messages after the user decided he doesn't want to see it anymore, the whole buisness of "Don't click this link" where you'd end up on an infinite loop of alerts if you did click it, would be made possible again. Nobody wants that.
I am trying to open a link in a new tab/window when a user presses a key.
Here is the function I made for opening a link, it gets called when the user presses the "X" key.
function open_link() {
window.open($("#active").attr("link"), '_blank');
}
My page consists of a bunch of divs looking like this, and the user sets the active one by navigating up/down with the keys j/k. All this works, but the problem is that there is a popup blocked warning when the "X" key is pressed to open the link.
<div class="read entry" id="active" entryNumber="0" entryId="733" link="http://www.reddit.com/r/buildapc/comments/1aux43/build_help_ordering_soon_final_review/">
I don't think you can disable popup blocker from javascript. If you could, then popup blockers would be quite useless.
Have you considered using modal divs instead? E.g. modal dialog from jQueryUI.
That is a problem that you can't avoid, popup blocking is a built in function that all the recent browsers have and getting around a pop-up blocker isn't going to get the user happy.
You can use a jquery/javascript alternative like on-request iframes or modal dialog windows
Just wondering.
I have a page in Jquery Mobile which uses a popup that opens as a fullscreen page on smartphone displays:
Desktop/Tablet:
Smartphone:
Problem is, if the user views the page on smartphone, this looks like a real page. When the user hits the "back" button I provide, I'm just closing the popover. However, if the user hits the browser back button, he's leaving the page, because he never went a page down in the history.
Question:
Since I can't disable the browser back button, is there another way to create a browser history entry when the popover opens, so when the user presses the back button, I'm simply closing the popover and the browser history is back on the initial page vs. going "-1". If there are other workarounds to achieve this I'd also appreciate any suggestions.
Thanks!
Maybe what you can do is add the popover as a dialog page if the webpage is opened from a smartphone (you can use user-agent to check for this). You might want to check http://jquerymobile.com/test/docs/pages/page-dialogs.html That way it will be added to the browser history.
Try adding a live Vclick.
or
you could try disabling the class ui,
Example:
class="ui-disabled"