FULL PRODUCT VERSION :
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
AppletContext.showDocument is used to display html content in a new browser window (e.g. when pushing a button in an applet). To be able to format the new browser window (size, location, decoration etc.) one has to use "javascript:" protocol and use window.open in Javascript (see also bug Id 6962852).
This is the preferred way of opening popup windows in Flash too (see http://www.macromediahelp.com/flash/pop_up_windows_in_flash/ )
However, in Java, using "javascript:" urls results in inconsistent behavior.
"javascript:" urls are not recognized on Linux at all (neither in Firefox 3.6, nor in Chrome).
In Chrome 7, Opera 9.62, Firefox 3.6 both "http:" and "javascript:" urls work with default popup blocking on when showDocument is called in response to a mouse click.
In IE7, IE8 and Safari 5 "http:" urls work but "javascript:" urls get blocked by the default popup blocker.
Moreover, in IE8 "http:" urls get opened in a new window behind the current one.
On all of the browsers above Flash works, formatted popup windows will be shown with default popup blocking (using "javascript:") urls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
call showDocument in response to a mouse click using a "javascript:" url that opens a formatted popup window using window.open
Compiled version of the source code along with the flash example can be tested here:
http://gs3.flyordie.com/popup-browser-test/JavaVsFlash/index.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
formatted popup windows should be displayed on all browsers with default popup blocking on (in response for a mouse click)
ACTUAL -
IE7, IE8 and Safari block popup windows.
No "javascript:" url support on Linux at all.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.applet.*;
import java.awt.event.MouseEvent;
import java.net.*;
/* requires javascript in html:
function openNewWindow(URLtoOpen, windowName, windowFeatures) {newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
*/
public class pop1 extends Applet {
private void paint(Graphics g, Color bgnd, Color col, String s, int y, int w, int h) {
g.setColor(bgnd);
g.fillRect(0, y, w, h);
g.setColor(col);
FontMetrics fm = g.getFontMetrics();
g.drawString(s, (w - fm.stringWidth(s)) / 2, y + (h - fm.getHeight()) / 2 + fm.getAscent());
}
public void paint(Graphics g) {
int w = getWidth(), h = getHeight() / 2;
paint(g, Color.black, Color.white, "http:", 0, w, h);
paint(g, Color.yellow, Color.red, "javascript:", h, w, h);
}
public void start() {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if(e.getID() == ((e.getModifiers() & MouseEvent.SHIFT_MASK) == 0 ? MouseEvent.MOUSE_CLICKED : MouseEvent.MOUSE_RELEASED))
try {
URL u;
String t;
if(e.getY() >= getHeight() / 2) {
u = new URL("javascript:openNewWindow('http://java.com','thewin','height=400,width=400,toolbar=no,scrollbars=no')");
t = "_self";
}
else {
u = new URL("http://java.com");
t = "_blank";
}
getAppletContext().showDocument(u, t);
System.out.println(u);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
supporting bug Id 6962852 would render this problem obsolete.
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
AppletContext.showDocument is used to display html content in a new browser window (e.g. when pushing a button in an applet). To be able to format the new browser window (size, location, decoration etc.) one has to use "javascript:" protocol and use window.open in Javascript (see also bug Id 6962852).
This is the preferred way of opening popup windows in Flash too (see http://www.macromediahelp.com/flash/pop_up_windows_in_flash/ )
However, in Java, using "javascript:" urls results in inconsistent behavior.
"javascript:" urls are not recognized on Linux at all (neither in Firefox 3.6, nor in Chrome).
In Chrome 7, Opera 9.62, Firefox 3.6 both "http:" and "javascript:" urls work with default popup blocking on when showDocument is called in response to a mouse click.
In IE7, IE8 and Safari 5 "http:" urls work but "javascript:" urls get blocked by the default popup blocker.
Moreover, in IE8 "http:" urls get opened in a new window behind the current one.
On all of the browsers above Flash works, formatted popup windows will be shown with default popup blocking (using "javascript:") urls.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
call showDocument in response to a mouse click using a "javascript:" url that opens a formatted popup window using window.open
Compiled version of the source code along with the flash example can be tested here:
http://gs3.flyordie.com/popup-browser-test/JavaVsFlash/index.html
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
formatted popup windows should be displayed on all browsers with default popup blocking on (in response for a mouse click)
ACTUAL -
IE7, IE8 and Safari block popup windows.
No "javascript:" url support on Linux at all.
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.*;
import java.applet.*;
import java.awt.event.MouseEvent;
import java.net.*;
/* requires javascript in html:
function openNewWindow(URLtoOpen, windowName, windowFeatures) {newWindow=window.open(URLtoOpen, windowName, windowFeatures); }
*/
public class pop1 extends Applet {
private void paint(Graphics g, Color bgnd, Color col, String s, int y, int w, int h) {
g.setColor(bgnd);
g.fillRect(0, y, w, h);
g.setColor(col);
FontMetrics fm = g.getFontMetrics();
g.drawString(s, (w - fm.stringWidth(s)) / 2, y + (h - fm.getHeight()) / 2 + fm.getAscent());
}
public void paint(Graphics g) {
int w = getWidth(), h = getHeight() / 2;
paint(g, Color.black, Color.white, "http:", 0, w, h);
paint(g, Color.yellow, Color.red, "javascript:", h, w, h);
}
public void start() {
enableEvents(AWTEvent.MOUSE_EVENT_MASK);
}
protected void processMouseEvent(MouseEvent e) {
super.processMouseEvent(e);
if(e.getID() == ((e.getModifiers() & MouseEvent.SHIFT_MASK) == 0 ? MouseEvent.MOUSE_CLICKED : MouseEvent.MOUSE_RELEASED))
try {
URL u;
String t;
if(e.getY() >= getHeight() / 2) {
u = new URL("javascript:openNewWindow('http://java.com','thewin','height=400,width=400,toolbar=no,scrollbars=no')");
t = "_self";
}
else {
u = new URL("http://java.com");
t = "_blank";
}
getAppletContext().showDocument(u, t);
System.out.println(u);
}
catch(Exception ex) {
ex.printStackTrace();
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
supporting bug Id 6962852 would render this problem obsolete.