Main Page

Internet Explorer on Windows XP

window smaller than 100 x 100, the window automatically opens up to 100 x 100. These rules, although
seemingly impractical, help to ensure that users are always aware of windows popped up from scripts.
You also can’t open windows that are larger than the user’s desktop. You can’t, for instance, open a win-
dow that is 1600 x 1200 on a screen that is 1024 x 768.
These same window position and dimension rules apply after the window has been created. You cannot
move a pop-up window off screen using
moveBy()
or
moveTo()
, nor can you resize the window to be
smaller than 100 x 100 or to be larger than the desktop using
resizeBy()
and
resizeTo()
.
Also a window cannot be closed using the
close()
method unless the window was opened using
win-
dow.open()
. If you try to close a window that wasn’t opened by script, a dialog is displayed asking for
the user’s permission to close to the window.
Most browsers now come with pop-up blockers built-in. Many non-technical users actually have no idea
whether or not pop-up blocking is turned on. Keep this in mind when designing your Web solution.
Typically, pop-up blockers work by blocking all pop-up windows that occur without user interaction,
meaning that you can’t open up a new window during events such as
load
and
unload
; pop-up win-
dows can only be opened during events such as
click
and
keypress
. However, some pop-up blockers
that block all pop-up windows without regard for user interaction. So how can you tell if one of your
pop-up windows has met with an untimely block?
The
window.open()
method typically returns a pointer to the newly created window. If the window
was blocked,
window.open()
usually returns
null
:
var oWindow = window.open(“page.htm”, “mywindow”);
if (oWindow == null) {
alert(“Your popup blocker won’t allow you access to this window.”);
} else {
//continue on
}
Some browsers (such as Mozilla) allow the end user to decide whether scripts
should be allowed to move and resize windows.
Internet Explorer on Windows XP Service Pack 2 exhibits a slightly different behav-
ior. It enables you to open windows off screen or at small sizes if the site you are vis-
iting is listed as trusted in Internet Options. Trusted sites are typically those accessed
using https://, but not necessarily. For any untrusted site, you receive a security warn-
ing if the site attempts to open the window. If you allow the pop-up, it has all the tra-
ditional limitations (can’t be opened off screen, can’t be opened to a very small size).
565
Deployment Issues
22_579088 ch19.qxd 3/28/05 11:43 AM Page 565


JavaScript EditorFree JavaScript Editor     Ajax Editor


©