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
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 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.
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.
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"
I have a web application, and I want to disable the Back button.
I read and found that I can open the browser without the navigation controls with the function window.open(...).
This is the code:
window.open (mywebappURL,"mywindow","status=1,toolbar=0");
I tried to put it in my Main.Master page, but I get an infinite loop and the new window is opened as a popup window of my application.
Does anyone knows where should I put this code to get my web application opened in a browser without navigation buttons?
Thanks,
Inbal.
try this on the link's onclick() event
function openPopup(){
var pathname = (window.location.pathname);
window.open(pathname+'somePopup.html','','width=800,height=450,resizable=yes,dependent,screenx=80,screeny=80,left=80,top=20,scrollbars=no');
return false;
}
and in the html
click me
To answer your question directly, make sure the window you're opening is a different URL than the window that's initially visited. So your visitor might arrive at www.example.com/index.html which then opens www.example.com/popup.html
If you open index.html again, the new copy will immediately open a popup, which will immediately open a popup, and there's your infinite loop.
However, as several people have commented already, this is generally discouraged. Among other disadvantages to this approach, popup blockers will likely interpret this as trying to launch a popup advertisement, forcing your visitors to recognize what's happened and change their settings.