Opening a new window from dhtmlxgrid avoiding pop up blockers - javascript

The reading of this Avoid browser popup blockers confirm my feelings that add blocker does simply allow popup that are opened by a user generated event.
I'm using dhtmlxgrid and get notified from a user click over one cell through the "onRowSelect" event but calling raise a problem with Firefox and Chrome ad blocker :
window.open(url, "_blank");
Any idea or magic solutions.

Are you using the Dhtmlx Window component? because that call window.open() is pure JS call.
You may try to create a DhtmlxWindow object that is a DIV and it should not be blocked, I used this before and never got problems.
Here's a simple INIT guide to use dhtmlx Window.
http://dhtmlx.com/docs/products/dhtmlxWindows/samples/01_init/01_minimal_init.html

Related

replacing window.showmodaldialog with window.open

In Many application, many of popups are implemented using window.showmodaldialog which restricts user to finish work on popup before changing focus to any other aprt of application. I want to change the implementation from modal dialog (window.showmodaldialog) to independent window (window.open). could you please help me with steps which has to be followed ?
It is quite simple window.open([URL], 'width=[some number],height=[some number]');.
In this if you have any return values with window.showmodaldialog which you are using in the opener window, you have to handle them with window.opener.
Have a look at https://developer.mozilla.org/en-US/docs/DOM/window.open http://www.w3schools.com/jsref/met_win_open.asp

How to identify a browser-window as a popup in Firefox-Extension?

We are a bit in trouble.
We show some informations for specific sites in our own firefox extension (for several reasons we use a xul box-Element for that presentation).
We don't wan't the box to show in browser popups.
But: How do we identify a browser-window as a popup in our extension code (javascript)?
Thanks a lot!
You may check:
if the window does have an opener => if(window.opener)
to determine if it was opend using javascript
if the window does have an opener, check if it is the top-window =>if(self==top)
to determine that the window is not a frame
When both conditions are true, you may assume that the window is a popup.

Strange Window popup behaviour on IE7

We have written a small javascript function which checks if a URL should open in same window or a popup. In cases when a url should open in a new window IE is giving some strange behaviour a window popup flashes and closes with a beep sound. Can anybody suggest whats going behind the scenes i do not think its my javascript which is wrong. Is it some browser weird behaviour.
I suspect you have a third party pop-up blocker installed.
Yep, this sounds like some third party stuff. By default IE will try to guess what it should do with popups (open in a popup window, open in a new tab, don't open at all) but it won't try to open a window and close it immediately (unless caused by some addons or code included in the page). JavaScript errors shouldn't cause the window to close either (unless they really call window.close()).

avoid the confirm dialog box when trying to close IE popup

How to avoid the confirm dialog box “the web page you are viewing is trying to close the window” when trying to close IE popup?
Make sure the window you are trying to close is one you opened with JavaScript, and not the one the user arrived at your site with (complete with history they might want to go back through).
This hack used to work in IE, but not sure if it still does:
window.opener = window;
window.close();

How can I trap the unknown cause of a Javascript popup?

I am debugging someone else's web page. There is a link on it which tries to open itself in a popup window, the reason for this is unclear -- there is nothing obvious in the HTML (onclick=foo) to cause this.
Disabling JavaScript means the link opens normally. I have Firefox/Firebug/Dom Inspector and would like to trap whatever JavaScript event is leading to the popup. Since I can't find the code, I'm stuck.
Can Firebug create a sort of global breakpoint to trap all code? Is there some other way to hook into this behaviour and inspect it?
The page in question is http://hijinxmusic.co.uk/ and the problem link is "Green Policy" near the bottom.
Thanks for your time.
The green policy document opens a popup with itself on load:
<body onload="MM_openBrWindow('green%20policy.htm','green','width=900,height=600')">
This is inside green policy.htm
Just to add to David's answer, the function that gets executed on body load in the page at http://hijinxmusic.co.uk/green%20policy.htm essentially calls window.open()
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
The bigger problem is that the page that you are trying to open in a new window is the same window that the user is already looking at, which doesn't make any sense. What's more is that if the popup blocker wasn't blocking window creation, you would have an infinite loop of popups (load green policy.html, open a new green policy.html, load green policy.html, etc). Where did you want the popup to happen?
Also, to add to Russ Cam's answer, you can detect when the popup fails to open by checking the return value of window.open. I have used this successfully in Firefox, IE, Opera and Safari (haven't needed to test in Chrome). Using the provided function, this is how I handle blocked popups:
function MM_openBrWindow(theURL,winName,features) { //v2.0
if ( !window.open(theURL, winName, features) ) {
// Window failed to open:
// show a HTML dialog/popover that prompts the user to allow
// popups from this site, along with a `cancel` and `try again`
// button. The `try again` button will attempt to open the
// window again with the provided parameters
dialog.popupBlockedNotice.open(arguments);
}
// Window opened successfully.
}

Categories

Resources