showDocument blocked by new microsoft pop-up blocker

M

Mickey Segal

As expected, the new Microsoft pop-up blocker that comes with the Windows XP
SP2 update blocks Java's showDocument method. This also happens with the
Google pop-up blocker (http://segal.org/java/pop_window/) but does not occur
with the Netscape or Apple Safari pop-up blockers.

Is there any way to detect whether the Microsoft or Google pop-up blocker is
on so one could re-direct the user to a page describing how to turn the
pop-up blocker off for a particular Web site? This over-zealous blocking is
a real bother if you need to pop-up documentation windows from a Java
applet. JavaScript-based user-initiated window pop-ups are not blocked; but
Java's showDocument is blocked.
 
P

Paul Lutus

Mickey said:
As expected, the new Microsoft pop-up blocker that comes with the Windows
XP
SP2 update blocks Java's showDocument method. This also happens with the
Google pop-up blocker (http://segal.org/java/pop_window/) but does not
occur with the Netscape or Apple Safari pop-up blockers.

Is there any way to detect whether the Microsoft or Google pop-up blocker
is on so one could re-direct the user to a page describing how to turn the
pop-up blocker off for a particular Web site?

No, but you could have a conspicuous Web page entry explaining the problem
and offering a remedy, for those who want it. For this, you have to own the
site and control its content.
This over-zealous blocking

Really. If it was overzealous, people would turn it off. That word is
redserved for those who create pop-ups, not the feature that prevents them
from appearing.
is a real bother if you need to pop-up documentation windows from a Java
applet.

Put the documentation in the applet, not over it.
 
M

Mickey Segal

Paul Lutus said:
... you could have a conspicuous Web page entry explaining the problem
and offering a remedy, for those who want it. For this, you have to own
the
site and control its content.

This is what we've done, with a big red notice that comes on if the browser
is Internet Explorer for Windows. If there were a good way for the Web page
to determine whether the user had a popup blocker enabled we could make the
notice more of a one-time in-your-face warning, but I am not aware of a way
to do so. Suggestions are appreciated.
Really. If it was overzealous, people would turn it off.

The Netscape pop-up blocker seems to do very well at blocking pop-ups and it
doesn't block showDocument.
 
J

Joona I Palaste

This is what we've done, with a big red notice that comes on if the browser
is Internet Explorer for Windows. If there were a good way for the Web page
to determine whether the user had a popup blocker enabled we could make the
notice more of a one-time in-your-face warning, but I am not aware of a way
to do so. Suggestions are appreciated.

If there was such a way, people would make their websites display only
an error message if the user didn't want to keep closing popup windows
advertising free medication, mortgages and inkjet cartridges every five
seconds.
 
A

Andrew Thompson

On 26 Aug 2004 07:28:34 GMT, Joona I Palaste wrote:

(Mickey Segal)
If there was such a way, people would make their websites display only
an error message if the user didn't want to keep closing popup windows
advertising free medication, mortgages and inkjet cartridges every five
seconds.

I have been mulling this over, Mickey.

Perhaps what we need is a more 'user empowered'
way of going about this.

My initial (jumbled) thoughts on this stratgey are..
a) Use an IE conditional statement to present
a message to users of IE.
b) Insert a call to 'showDocument' in that page,
requesting a small page that has the message
'Show Document successful'
c) *Ask* the user in a form in the original page
whether they see the message 'Show Document successful'.
d) If they do, go to the normal page, else
go to a safe 'fall-back' page.

...as an 'extra points' measure, you might, of course
show the original message to *all* users and ask them if
a) they can see the message
b) (&, if yes) ..if they would like to receive
the extra functionality that can be provided
through it's use.

(You might be surprised to find a lot of people choose
a slightly lesser abled version with no pop-ups..)

Might that work for your situation?
 
M

Mickey Segal

Andrew Thompson said:
Insert a call to 'showDocument' in that page,
requesting a small page that has the message
'Show Document successful'

If I wanted to present a test pop-up window to all users I could do that
from the HTML page using JavaScript (as we do using window.open in the page
users see after following our red warning about pop-up blockers). But I am
trying to avoid showing a pop-up window to all users; the idea is to show it
only to users who have not yet added our site to their whitelist of sites
allowing pop-ups.

The 4 things that bother me about this blocking of showDocument are:
1. Agreeing to add a site to a pop-up blocker's whitelist of sites that
allow pop-ups once an applet is running TERMINATES the applet, a poor
customer experience.
2. There seems to be no good way to detect the pop-up blocker from an HTML
page and use this information to send the user to a page directing them to
turn off blocking for our site. The best I can think of is to actually run
our software from a HTML page in a pop-up window and have the original
browser window be directions about turning off pop-up blockers. However,
that seems kludgey, leaves an extra window open, and doesn't leave the user
a choice about leaving the pop-up documentation blocked if they would prefer
no documentation screens.
3. Pop-up blockers don't block user-initiated pop-ups in an HTML page but
they do block user-initiated pop-ups from Java. Java should not have fewer
privileges than its HTML page.
4. Users have already accepted our digital certificate, but we still get a
level of privileges less than those of a regular HTML page.
 
J

Joona I Palaste

Andrew Thompson said:
On 26 Aug 2004 07:28:34 GMT, Joona I Palaste wrote:
(Mickey Segal)
I have been mulling this over, Mickey.
Perhaps what we need is a more 'user empowered'
way of going about this.
My initial (jumbled) thoughts on this stratgey are..
a) Use an IE conditional statement to present
a message to users of IE.
b) Insert a call to 'showDocument' in that page,
requesting a small page that has the message
'Show Document successful'
c) *Ask* the user in a form in the original page
whether they see the message 'Show Document successful'.
d) If they do, go to the normal page, else
go to a safe 'fall-back' page.
..as an 'extra points' measure, you might, of course
show the original message to *all* users and ask them if
a) they can see the message
b) (&, if yes) ..if they would like to receive
the extra functionality that can be provided
through it's use.
(You might be surprised to find a lot of people choose
a slightly lesser abled version with no pop-ups..)
Might that work for your situation?

Why did you reply to my message instead of Mickey's, when the whole
content of your reply was directed to Mickey, and did not address my
comments at all?
 
M

Mickey Segal

Joona I Palaste said:
If there was such a way, people would make their websites display only
an error message if the user didn't want to keep closing popup windows
advertising free medication, mortgages and inkjet cartridges every five
seconds.

In our case, people accept a digital certificate to use our applet. It is
strange than a digitally-signed applet is given lower security permission
than a regular HTML page, where if a user clicks a button to pop up a new
Web page that is allowed. From Java, if a user clicks a button to pop up a
new Web page that is not allowed, even if the applet is digitally signed.
Java, particularly signed Java, was supposed to be an environment where you
could do more than in a HTML page.

If there were a way of detecting whether the user has a pop-up blocker and
re-directing to a special page describing how to put the site on a whitelist
that would be OK, but the system as currently implemented by Microsoft and
Google doesn't work well. Google has further problems as detailed at
http://segal.org/java/pop_window2/ but they even acknowledge that blocking
showDocument in the first place was in http://segal.org/java/pop_window/ is
a bug. It is striking that the Netscape and the Apple safari pop-up
blockers do not block showDocument, even though they seem to do a more
thorough job blocking pop-ups than Google's pop-up blocker.
 
A

Andrew Thompson

....
Why did you reply to my message instead of Mickey's, when the whole
content of your reply was directed to Mickey, and did not address my
comments at all?

My apologies Joona..

I actually thought your point about people not
wanting pop-ups was relevent. I hate them myself..

I seem not to have adequately expressed the
connection, or perhaps there was no connection
in the first place, alternatively I completely
missed your original point?

[ Now that I look closely at what you wrote,
I am suspecting c) ]
 
M

Mickey Segal

Andrew Thompson said:
I have been mulling this over, Mickey.

I think I may have figured out a strategy using JavaScript:
1. Pop-up a test window and have it close itself (closing requires no user
action since the window has no history).
2. Use the results of the popping to determine whether the user is allowed
to continue using the software or sent to a page describing how to allow
pop-ups on our site.
 
A

Andrew Thompson

I think I may have figured out a strategy using JavaScript:

....hhhm. I have seen a few responses on c.l.js
that suggest attempts to detect pop-up success
using JS are unreliable.. I am not sure whether
that extends beyond 'JS disabled', but I would
whip up a test case and ask the goodly JS folks
to break it for you..

[ They have certainly been doing a great job
with my attemps to come up with the most enabled
use of <OBJECT>/<APPLET> elements ;-) ]
 
A

Andrew Thompson

In our case, people accept a digital certificate to use our applet.

Signed ehh?

<sscce>
import java.applet.Applet;

import java.awt.Button;
import java.awt.TextArea;
import java.awt.Label;
import java.awt.Checkbox;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.BorderLayout;
import java.awt.FlowLayout;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import java.net.URL;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.MalformedURLException;

import java.io.IOException;

/** This Applet queries the success of
openning a web-page using showDocument().
The 'pop-up' opens a server socket that
the original page attempts to connect to.

This code requires security access to
establish sockets, so short of altering
the policy file of the browser, it will
only run as signed code.

This version opens a dialog asking the user
if they wish to proceed with the test, even
after they have accepted the applet through
the JVM.

@author Andrew Thompson
@version 2004-08-24 */
public class ShowDocumentTestApplet
extends Applet implements ActionListener {

/** The URL of the target (pop-up) web page. */
URL target = null;

/** The 'pop-up' is a ServerSocket.. the openning page
is a client that attempts to detect the server socket,
and uses that to determine success of the pop-up window. */
boolean server = false;

/** The server socket which the pop-up creates, and the source
page attempts to detect. */
ServerSocket ss;

/** Default port number */
int port = 21219;

/** Establish port number and role, and
set-up the GUI and resources for each. */
public void init() {

String sPort = getParameter("port");
try {
port = Integer.parseInt(sPort) ;
} catch (NumberFormatException nfe) {
// use default port
} catch (NullPointerException npe) {
// use default port
}

String tempRole = getParameter("role");
if ( tempRole!=null ) {
// the 'target' roles opens a ServerSocket, so that the
// original 'source' applet can connect to it (or not)..
server = tempRole.trim().toLowerCase().equals("target");
}

if (server) {
// This is the pop-up. It establishes a server socket so that
// other applets can test for that socket.
try {
// start the server socket, so that the
// openning page can test for it..
ss = new ServerSocket(port);
add( new Label("Server active on port: " + port ) );
showStatus( "Server socket created at port: " + port );
}
catch (UnknownHostException uhe) {
uhe.printStackTrace();
}
catch (IOException ioe) {
ioe.printStackTrace();
}
catch (SecurityException se) {
se.printStackTrace();
}
} else {
// This page launches, and tests for,
// the page that has (maybe) pops-up..
Frame f = new Frame("");

// ..but only if the client specifically agrees.
WarningDialog wd = new WarningDialog(f);
wd.setVisible(true);
wd.toFront();
setLayout(new FlowLayout());
if ( wd.isApproved() ) {

Button b1 = new Button("Applets");
b1.addActionListener(this);
add(b1);

Button b2 = new Button("Show Document");
b2.addActionListener(this);
add(b2);

try {
String s = getDocumentBase().getFile();
s = "file:" +
s.substring(0,s.lastIndexOf("/")) + "/target.html";
target = new URL(s);
} catch (MalformedURLException murle) {
murle.printStackTrace();
}
} else {
add(new Label("Pop-up test declined by guest."));
}
}
}

/** Ensure the server socket is disposed. */
public void dispose() {
if (ss!=null) ss = null;
}

/** Check for the existence of the server socket by attempting to
connect to it. If the connection is successful, return true. */
public boolean isServerSocketActive() {
try {
Socket s = new Socket("localhost", port);
}
catch (UnknownHostException uhe) {
uhe.printStackTrace();
return false;
}
catch (IOException ioe) {
ioe.printStackTrace();
return false;
}
catch (SecurityException se) {
se.printStackTrace();
return false;
}
return true;
}

/** Show the target document, or test for it, as needed. */
public void actionPerformed(ActionEvent ae) {
if ( ((Button)ae.getSource()).getLabel().equals("Applets") ) {
showStatus( "Server socket detected: "
+ isServerSocketActive() );
} else {
getAppletContext().showDocument(target, "_blank");
}
}
}

/** The user/client warning dialog used in this example that
ensures the client is informed of the reason for the test.
@author Andrew Thompson
@version 2004-08-24 */
class WarningDialog extends Dialog {

Checkbox approved;

/** Construct a simple warning message dialog. */
WarningDialog(Frame f) {
super(f, true);
setLayout(new BorderLayout());
String sep = System.getProperty( "line.separator" ),
message = "Warning!" + sep + sep +
"This applet attempts to open 'pop-up' windows." + sep +
"Check the box below to proceed." + sep + sep +
"If you close the dialog without agreeing," + sep +
"the test will not proceed." + sep + sep +
"Should you change your mind, " + sep +
"simply refresh the page.";
add(new TextArea(message), BorderLayout.CENTER);
approved = new Checkbox("Agree");
add(approved, BorderLayout.SOUTH);

pack();
setSize(getPreferredSize());

addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent we) {
setVisible(false);
}
} );
}

/** Has the user approved the pop-up test? */
public boolean isApproved() {
return approved.getState();
}
}
</sscce>

[ index.html ]
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-1">
<title>Applet showDocument() experiment</title>
<meta name="author" content="Andrew Thompson">
</head>
<body>
<div>
<applet alt='Java Disabled! (applet)'
code='SignedShowDocumentTestApplet1.class'
archive='SignedShowDocumentTestApplet1.jar'
width=220 height=100>
</applet>
</div>
</body>
</html>
[ end: index.html ]

[ target.html ]
<!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=iso-8859-1">
<title>Applet showDocument() experiment</title>
<meta name="author" content="Andrew Thompson">
</head>
<body>
<div>
<applet alt='Java Disabled! (applet)'
code='SignedShowDocumentTestApplet1.class'
archive='SignedShowDocumentTestApplet1.jar'
width=200 height=100>
<param name='role' value='target'>
</applet>
</div>
</body>
</html>
[ end: target.html ]

How's that go for you Mickey?
 
M

Mickey Segal

Andrew Thompson said:
...hhhm. I have seen a few responses on c.l.js
that suggest attempts to detect pop-up success
using JS are unreliable.. I am not sure whether
that extends beyond 'JS disabled', but I would
whip up a test case and ask the goodly JS folks
to break it for you..

I've put my JavaScript code on a working example at:
http://segal.org/js/pop_detect/
It is not very elegant but it does seem to work in Internet Explorer for
Windows, which is the only environment for which I would enable pop-up
testing since showDocument is not blocked by the Netscape pop-up blocker and
the Apple Safari pop-up blocker.

Does anybody have any comments before I ask the experts at c.l.js about this
JavaScript-newbie code? Nobody knows me there are they are liable to assume
the worst about my interest in pop-up detection. At least people on this
group know that there are many legitimate examples of using event-driven
calls to showDocument.
 
A

Andrew Thompson

I've put my JavaScript code on a working example at:
http://segal.org/js/pop_detect/

Try this variant..

<!doctype html public "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<title>Pop-up blocker detection</title>
<script type='text/javascript'>
function isBlockingPopUps() {
result = window.open("popped.html", "popped",
"width=10, height=10, location=no, \
menubar=no, status=no, toolbar=no, \
scrollbars=no, resizable=no");
return result=='undefined';
}
</script>
<style type='text/css'>
div {
border: solid 2px red;
padding: 10px;
}
</style>
</head>
<body>
<h3>Pop-up blocker detection</h3>
<p>If any message appears in the red box below, it may indicate
a problem with this browser's ability to display pop-ups.
<div>
<!-- display only to IE -->
<!--[if IE]>
<p>This browser is potentially affected.
<script type='text/javascript'>
document.write( "<p>Your browser is " );
if ( !isBlockingPopUps() ) {
document.write( "<em>not</em> " );
}
document.writeln( "blocking pop-ups.");
</script>
<noscript>
<p>This browser has Javascript disabled, and as a
result we cannot check pop-ups.
</noscript>
<![endif]-->
</div>
</body>
</html>


...it is valid, and degrades gracefully.

But I suspect it still has a fatal flaw..

Some pop-up blockers will open the window
only to clos it *themselves*, so.. to JS,
it appears to be defined.

Perhaps a good thorough search of the
JS archives might be in order..

<http://google.com/groups?as_q=detect pop&as_ugroup=comp.lang.javascript>

HTH
 
M

Mickey Segal

Andrew Thompson said:
Try this variant..

I was not trying for the general bullet-proof solution. I was just doing an
existence proof of a pop-up detector. We would use this code in a page that
requires JavaScript anyway and redirects to our applet or to a Allow Popups
for our Domain page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top