Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Window - Compatability

Status
Not open for further replies.

dalar

Programmer
Sep 19, 2004
18
0
0
GB
HI, in recent months I have had some trouble with the classic window.open..... command for opening and customizing new windows with content....

the problem is all these new "popup blockers" that soo many users seem to have.

My particular popup will be invoked by a click on a link instead of the onload event. - but even with this method, some of my windows fail to open due to the popup blocking software.

Is there any version of the code which is 'safe' to use, without having to ASK users to disable their popup blockers?

thanks guys
 

No. Have a think about what you are asking and why it is not possible!

If a user chooses to install a popup blocker with "maximum security" (i.e. allowing no popups), why should a developer ever be able to override that?

Dan


The answers you get are only as good as the information you give!

 

Incidentally, you can (and I wish most sites would!) detect that your popup has been blocked, and alert the user to this fact, rather than just erroring or doing nothing.

Dan


The answers you get are only as good as the information you give!

 
hey dan

Thanks for your thoughts ....

I presumed the main annoyance of a popup was when it is initiated automatically (hence onload event).

Where as a user click a link, and opening the page in a new customized window wouldnt be so rude as the conventional spamming popups - but yeah I guess the software blocks them all out.

Any links to where I can find a snippet of code for detecting anti-popup programs?

Thanks
 

I don't know of any code that will detect the presence of anti-popup programs... Perhaps some ActiveX control will do that?

Detecting that your popup has been blocked is a different thing, of course. If you assign the value returned from the window.open command, you can test if it is undefined (or is it null?) to see if the open went ahead or not.

Hope this helps,
Dan


The answers you get are only as good as the information you give!

 
I don't think that will work cross-browser. I don't have the code here at work, it's at home, but I ran into a problem between Firefox and IE in trying to detect whether a popup window was blocked. It took me quite some time to figure out a way to do it for both browsers. I think the problem had to do with the popup blocker in IE actually returning a handle to something when it blocked a popup.


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
I ran into a problem between Firefox and IE in trying to detect whether a popup window was blocked. It took me quite some time to figure out a way to do it for both browsers.

Odd - it really should have been fairly straighforward. This works for me in both IE6 and FF1:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		function openWin() {
			var winHandle = window.open('[URL unfurl="true"]http://www.google.co.uk/',[/URL] '', '');
			if (winHandle == null) alert('Popup was blocked');
		}
	//-->
	</script>
</head>
<body onload="openWin();">
</body>
</html>

Hope this helps,
Dan


The answers you get are only as good as the information you give!
 

In fact - I've put it in the FAQ section now:

faq216-5752

Dan


The answers you get are only as good as the information you give!

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top