Google Toolbar prevents open a new window - javascript

Google toolbar is creating a serious problem for me in IE 6 when i try to open a window using window.open or if i set target="_blank" for anchor tag. It treats the window as pop up and dispaly pop up is blocked which i really don't want to dsiplay to my user. This problem only occurs if there is a extra code getting executed before window.open, e.g. calling another method at onclick then using window.open. Can somebody tell me how to solve this issue?

The toolbar and other devices like that are intended to protect users from unwanted popup windows. The only way for them to determine whether a window is "wanted" is to determine whether window.open is being called in an event handler for a user-initiated event, like a button click. Thus if you try to do something like call window.open on document load, or in an AJAX success handler, the toolbar (and other blockers) will assume that the popup is suspect.
There's nothing you can do about this other than, as noted by Mr. Buchan, tell your users what to expect. Wherever possible, have your popups launched directly from click handlers.
A more radical change would be to shift away from window.open and use simulated popup windows made from floating elements that cover up part of the page. Something, that is, like what jQuery UI dialogs give you.

Adding the site to your Trusted Sites will work.
Setting target="_blank" shouldn't be triggering a pop-up blocker.

Related

Allow popup in Greasemonkey script [duplicate]

How to make pop up blockers allow your popup windows?
In general, by popping them up from within the event handler of a user-generated event. For instance, if you have a link and the user explicitly clicks it and you raise a popup from the onclick handler on the link, most popup blockers will allow the popup because of the user's explicit action. In contrast, popups from the window.load event, or code executing as a result of a setTimeout or setInterval call, will typically be suppressed.
Somewhat OT, but: If you can avoid using a pop-up, I would. I'd say (unscientifically) that 95-99% or so of the use-cases where people think they need a pop-up, there's a better design solution. But the answer above is there for those 1-5% situations. :-)
You should use a jQuery UI Dialog, which the popup blocker will not affect.
Users have to set that manually. Imagine what would happen if web apps were allowed to override popup blockers.
You can't. It's up to the user to configure their software to allow pop ups. As a general rule, pop ups generated by user input (i.e. clicking on a button) is usually allowed by most pop up blockers. But this isn't a definitive rule and we can't change it programmatically. If we could it would make pop up blockers useless.
Display a message nicely asking the user to unblock your popups. Obviously the whole point to popup blockers is so you, the site developer, can't forcibly defeat them.
One solution is to make them appear on your page rather than as an actual pop-up (which you can do pretty easily with jquery). If that's not appropriate in your case, asking nicely is a good option.
In your own browser … it depends on the browser and/or third party popup blocker.
When you have no control over the client — open the popup in response to a user generated event (such as onclick).

How do I prevent browsers from blocking the pop-up window that I've created?

I created a simple JavaScript function to display my pop-up window once it loads. But it keeps on being blocked by Firefox and Google Chrome and I have to somehow enable it on the Firefox and Chrome to display the pop-up.
Are there any alternatives for this?
I have a player on the pop-up window so I have to use a pop-up to let the player play automatically. The problem is that if I put it on the page itself, once the user clicks another page the entire page reloads and the player automatically stops for a few seconds until the whole page reloads and I have to prevent this from happening.
The general rule is that popup blockers will engage if window.open or similar is invoked from javascript that is not invoked by direct user action. That is, you can call window.open in response to a button click without getting hit by the popup blocker, but if you put the same code in a timer event it will be blocked. Depth of call chain is also a factor - some older browsers only look at the immediate caller, newer browsers can backtrack a little to see if the caller's caller was a mouse click etc. Keep it as shallow as you can to avoid the popup blockers.
Please take a look at dthorpe's answer here. It covers your question.
You could try putting the player on the original page, and using something like History.js to control page changes (you could have the main page body in one wrapper div that changes, and leave the player outside of it).
Otherwise, you could try (assuming you meant a HTML5 <video> or <audio> player) downloading the data to localStorage/cookie/[other persistent storage mechanism] and have it seek everytime you change a page.
It will be hard to stop browsers from blocking your pop up window, because any way to do so is inherently exploitable; however, if you call the function to open another window from an onclick event, you may be able to circumvent some popup blockers. Also, some popup blockers allow popups when using the https protocol, although not many have this feature, and https can be hard to implement for the average website, if you don't have physical access to the server.
One other option is to open the other page in another tab (like this w3c example; you can 'click' the link with javascript).
You might also want to look at this post, as it is somewhat similar.
I only just discovered you asked this question.
Here's the answer in full.
Basically, you can simply create the popup immediately as the user event is fired, then fill it with content (your player, for instance) as you have it available.

How to disable maximize,mimimize and close button for a new window open

I am using window.open() method to open a page as a pop-up window for a link button click event.
But the poup-up window is having minimize,maximize,close(x) button.
I dont want those buttons. How can remove these buttons?
This is the method i am using,
window.open(url,"Link","toolbar=0,location=0,directories=0,status=0,menubar=0,titlebar=no,scrollbars=1,resizable=0,width=450,height=310,left=500,top=350");
Tell me how can do this.
Regards,
Chirag Jain.
You can't.
If you want a popup style window without full window decorations you'd have to create a new overlay <div> on top of the existing content and fill that with content, perhaps using an <iframe>.
You can't do it from javascript alone. Think about it, if you could, then people could put it into code on web-pages and cause other people's computers to open windows they couldn't easily close.
Instead you'll have to look for an answer specific to whichever browser you're using to host this application, and change it on the computers of your users appropriately. Even then though I don't think you'll be in luck (with Firefox for example, I can see how to get rid of them on all browser windows, but not on just one).

disable onclick ads with a content-script in Google Chrome

There are some video streaming sites that pop up an ad anytime you click anywhere on the page. The problem is, you have to click on the page to press play! So I was thinking of making a UserScript that disables the script that does this. The only problem is, I already disable all the scripts on the site and when I do it still pops up. Is there a way that I can disable them ? I'm also using jQuery, so if I can do it through their interface, that would be great.
edit: Two perfect examples of such sites are daclips.in and gorrilavid.in
I have Adblocker Plus, and it seems like it is not recognizing "on Click" events as pop-ups, rather normal clicked links. And the logic is simple, no Adblocker will block you from clicking something intentionally and it (the link) opening in another window/tab.
The problem is the new window contains your clicked Url, while the original window/tab "Refreshes" (i.e. redirects) to another url.
Advertising companies seem to use this trick to bypass adblocking software.
Just ditch Chrome and use Firefox. Firefox already have built-in mouse-click popups. I think all addons like Adguard or Adblock can not disable mouse-click popups. If you use Firefox, these are the steps:
Type about:config in the browser's address bar and hit the enter key.
First time users need to confirm that they be careful on the next page.
Type or paste dom.popup_allowed_events into the search field.
The value of the preference highlights all events that are allowed to spawn popups.
Edit the value to remove some or all of the items here.
Why not just use a browser extension such as AdBlock?
https://chrome.google.com/webstore/detail/adblock/gighmmpiobklfepjocnamgkkbiglidom?hl=en
My go-to is right click and open in new tab. onClick events only happen with a left click. It's cumbersome but it still ends up being less work than closing the pop-up and whatever annoying prompts it may have.
I do not there's a practical solution for this.
Moreover, I think some of the answers here are missing the specific case in OP, where clicking anywhere on the page will cause the pop up to happen, not just clicking on links. According to this, neither right-clicking then choosing "open", nor noticing and blocking the target URL will help. I do not know of an add blocker that helps here either, because it's not trivial to meaningfully filter a click event that is taking place on the whole page object.
Only the solution provided by #Monkey would work, at the drawback of possibly breaking other things.

Popup a message upon exiting a webpage

We'd like to have a message popup when a visitor to specific webpages leave those webpages. So we could tie some Javascript to the links on those webpages, but then we can't control if the user exited the webpage by typing in a URL, using a bookmark or just closing the window...
I assume we have limited options if the user tries closing the browser window... but I do know it's possible because Google Docs' Documents offers the chance to cancel closing the window if you have unsaved work while closing the browser.
What are my options? Can I have Javascript called upon going to another webpage? Can I control the text in the popup when trying to close the window?
I'm using jQuery, so if there are good solutions implemented with jQuery that's perfectly fine.
Yes.
https://developer.mozilla.org/en/DOM/window.onbeforeunload
jQuery UI Dialog OnBeforeUnload
There is onunload event you can bind to, first example:
http://www.codetoad.com/javascript/miscellaneous/onunload_event.asp

Categories