Research on Pop-up Blocker in Windows XP Service Pack 2

Source: Internet
Author: User

1 Introduction
1.1 Research Background
Microsoft officially released the expensive Windows XP Service Pack 2 (English version) in August 2004, not a simple patch package upgrade, but a Windows System update that incorporates many new technologies. Microsoft claims that SP2 has solved many of the previous system vulnerabilities and has greatly enhanced Windows security. For web developers, it is worth noting that SP2 has added the pop-up (Pop-up Blocker) feature to IE, which will affect most of the world's use of pop-up windows. Although previous browsers such as Netscape have joined the feature, and Google and China's search company launched the toolbar also contains this feature, but for the majority of the market share of IE, the upgrade is significant. Because occupy the browser market 80% share above ie, each site should not accidentally use pop-up windows.

1.2 reference materials
1 Microsoft Windows XP Service Pack 2 feature Change http://www.microsoft.com/china/technet/prodtechnol/winxppro/maintain/ Sp2chngs.mspx
2 Fine-tune your Web site to accommodate Windows XP Service Pack 2 http://www.microsoft.com/china/MSDN/library/Windev/WindowsXP/ Usdnwxpxpsp2web.mspx
3 Windows XP Service Pack 2 training for Developers Http://msdn.microsoft.com/security/productinfo/XPSP2/introduction.aspx
4) MSDN http://msdn.microsoft.com http://www.microsoft.com/china/msdn/


2 Project Overview
2.1 Research purposes
Study the Pop-up Blocker features and principles of IE in Windows XP Service Pack 2 to find the solution to the pop-up window of the site under IE (SP2).

2.2 Test environment
Windows XP Professional Version 2002 + Service Pack 2
Internet Explorer 6.0.2900.2180

2.3 Project Cycle
August 26, 2004-September 20
About 40 hours.

3 Project Content
Introduction to 3.1 Windows XP SP 2
Windows XP Service Pack 2 has made many significant improvements to the operating system to enhance the security of personal computers. It can withstand the usual attacks, network protection, memory protection, enhanced e-mail security, and a more secure browsing of the Internet in four ways. Service Pack 2, on the other hand, provides a more convenient system update. Administrators can more easily control enterprise network security, users can easily use Bluetooth devices. Service Pack 2 also includes DirectX 9 and Windows Media Player 9, which includes security, performance, and functionality improvements.

With Windows XP Service Pack 2 (SP2), Microsoft introduced a set of security technologies that will help improve the ability of Windows xp-based computers to withstand malicious attacks from viruses and worms. These technologies include:
• Network protection
• Memory protection
• Enhanced E-mail Security
• More secure browsing

3.2 Pop-up Blocker

Windows XP SP2 adds Pop-up Blocker (Pop-up Blocker) to Internet Explorer, which blocks or masks most pop-up windows. Windows that are opened by the end user clicking on the link will not be affected, and pop-up windows from the local network and trusting site domains will not be blocked.

Pop-up Blocker is turned on by default, which prevents pop-up windows that are automatically opened and open in the background, but the user clicks on the link to open a window that can still be displayed correctly.

Enable Pop-up Blocker
You can enable Pop-up Blocker using three different methods.
• Tips for the first time you appear
Prompts to ask the user if Pop-up Blocker is enabled before the first pop-up window appears.
• Tools menu
In Internet Explorer, on the Tools menu, click the Screen pop-up window, and then click the Block pop-up window.
Internet option.
On the Internet Explorer Tools menu, click the Internet option, click the Privacy tab, and then click the Screen pop-up window. Then click on the option to set the Pop-up Blocker.

When a pop-up window is blocked:
When a site's pop-up window is blocked, a notification and playback sound is displayed on the status bar, and the InfoBar appears below the top address bar of the display area (you can not play the sound and display the InfoBar, see the Advanced Settings option later). Click the notification on the status bar to see a menu with the following options:
• Displays blocked pop-up windows. Reload the pop-up window.
• Allow pop-up windows from this site. Adds the current web to the Allow list.
• Block pop-up windows. Turn Pop-up Blocker on or off.
• pop-up window options. Open the Pop-up Window Management window.

The InfoBar displays a pop-up window blocked message and notifies the user that a pop-up window and other settings can be allowed by clicking the InfoBar:
• Displays blocked pop-up windows. Reload the pop-up window.
• Allow pop-up windows from this site. Adds the current web to the Allow list.
• Set whether to block pop-up windows and display information bars and more advanced settings.
• Information Bar Help.


Advanced Settings Options
Trust Site List
End users and IT administrators can allow automatic pop-up windows for these sites by adding some sites to the list of trusted sites.

Filtering level settings and other options
Three kinds of filtration level:
Advanced: Block all pop-ups (you can click the link to open the window by holding down the ALT key)
Intermediate: Block most automatic pop-up windows (default level)
Low level: Allow pop-up windows for secure sites
Other options:
Whether to play a sound when a pop-up window is blocked
Whether to display the InfoBar when a pop-up window is blocked

* The following will be in the default setting of Pop-up Blocker unless specifically marked.

Blocking mechanism
Pop-up Blocker will block any windows that are automatically opened from the script except for the Createpopup () (IE5.5 and above version support, see appendix). Some common functions that are affected by this are: window.open (), showModelessDialog (), ShowModalDialog (), ShowHelp (), Window.external.NavigateAndFind ().

Check method
In the existing data, Microsoft has not yet provided the ability to detect whether the user has turned on IE blocker, but provides a way to check if the window is blocked.

For window.open () open windows, when the window is blocked, the function returns a null value. When a pop-up is blocked, always check the value before using the return value of window.open () to avoid scripting errors.
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>popup tester</title>
<script language=javascript >
function Openwin ()
{
var Sreturn = window.open ("http://www.creative.com");
if (Sreturn = null)
{
errorlog.innerhtml = "Pop-up blolcked.<br/>the Window object return <font color=red>" + Sreturn + "</font& gt; ";
}
}
</script>
</HEAD>
<body onload= "Openwin ()" >
<div id= "ErrorLog" ></div>
</body>
</HTML>
This example shows how to check the function return value to determine whether a pop-up window opened with the window.open () method is blocked.

For windows that are automatically opened by using showModelessDialog (), ShowModalDialog (), ShowHelp (), there are two ways to handle a pop-up window being blocked:
1 if the browser version is IE 5.0 and above, you can use the Try/catch structure in JavaScript code to handle it. As shown in the following code:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>popup Tester-try/catch construct</title>
</HEAD>
<body onload= "Openwin ()" >
<form id= "Form1" method= "POST" runat= "Server" >
<div id= "ErrorLog" ></div>
</form>
</body>

<script language=javascript >
function Openwin ()
{
Try
{
window.showModalDialog ("www.creative.com");
}
catch (E)
{
errorlog.innerhtml = "pop-up blocked.<br/>";
errorlog.innerhtml + = "Error number:" + e.number;
}
}
</script>
</HTML>
In this example, a window that is automatically opened by the Openwin () function when the page is initialized is blocked and displays the error message and the error code.

2 Set the JavaScript error handle to the function that opens the window. As shown below:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<HTML>
<HEAD>
<title>onerror event</title>
</HEAD>
<body onload= "ShowPopup ()" >
<div id= "ErrorLog" ></div>
</body>

<script language=javascript >
function Handlepopuperrors (SMSG, sURL, sline)
{
errorlog.innerhtml = "<b>an error was thrown and caught.</b><p>";
errorlog.innerhtml + = "Error:" + sMsg + "<br>";
errorlog.innerhtml + = "line:" + sline + "<br>";
errorlog.innerhtml + + "URL:" + surl + "<br>";
return false;
}
function ShowPopup ()
{
Window.onerror = handlepopuperrors;
window.showhelp ("http://www.creative.com", "");
}
</script>
</HTML>
This example illustrates the exception information that is used to trap the window when it is blocked by setting the error handle. As in the above approach, you can use this method to notify users to disable Pop-up blocker or to add sites to a trusted site domain to view pop-up content.

Some inappropriate measures.
1 Redirect or close the window depending on the pop-up window being blocked
When a site pop-up window is blocked and redirected, it is not possible for the user to access the pop-up content through the InfoBar.
Similarly, if a window is closed because it is blocked from popping up, the user will not be able to see the InfoBar.

2 launch pop-up window from pop-up window
Pop-up Blocker blocks any windows that automatically pops up, even if you start a new pop-up window from a pop-up window.

3 do not automatically start the setHomePage () dialog box
As with pop-up windows, the setHomePage () prompt that is automatically started will be blocked.

4 When the information is requested asynchronously, the site does not open a new window
If a site opens a specific window after an asynchronous request for information, Internet Explorer may block these windows, even if the user clicks the link to open the window.

5 Do not start pop-up windows from ActiveX controls or other objects
For other pop-up windows, if the window is not started from a user action, the pop-up blocker blocks it. A window must respond to a direct user operation before it is allowed to be opened.

General Pop-up recommendations
• Do not redirect when a pop-up window fails.
• If pop-up, download, or ActiveX controls are blocked, do not close or automatically redirect the browser window. If you close or redirect the browser window, users will not be able to click on the InfoBar and accept pop-up windows, downloads, or ActiveX controls.
• Do not start pop-up windows from the pop-up window.
• Do not start multiple pop-ups from a user action.
• Do not start an automatic pop-up window from a showmodelessdialog () or ShowModalDialog () call.

3.3 Pop-up Window Restrictions
Do not set the script so that the pop-up window's title bar, Address bar, or status bar leave the viewable area of the screen. Service Pack 2 Restricts windows that are ejected by using the window.open () or Window.createpopup () method to ensure that all the information in the window is visible.

1 for windows that are open with window.open (), make sure the status bar is displayed and that the window does not overwrite the taskbar. If the pop-up window is positioned outside the screen, the window restriction adjusts the x and Y coordinates of the window so that it is fully displayed on the screen. In addition, the window.open () with Fullscreen=yes now results in a maximized window, not a Kiosk-mode window. Regardless of the width and height of the pop-up window, it is limited to the screen.

Note: Kiosk mode is a Web browser mode that does not display any browser controls (such as toolbars)

As shown in the figure above, a pop-up window opened through window.open () may overwrite the taskbar or the parent window, so make sure that the pop-up window is designed correctly.

2 windows that are opened using Window.createpopup () will not overwrite the parent window's title bar or status bar, so even if the height of the window is set to exceed the parent window or screen size, SP2 will still limit its guarantee to the parent window's title bar or status bar. In addition, if the user does not maximize the parent window, the pop-up window may be outside the parent window or even partially or completely outside the screen when the parent window is in a different position on the screen.

In the diagram above, the window (blue border, red background portion) opened by Window.createpopup () is set to 1400 in the script, high 900, but when displayed, the pop-up window is limited to the height to guarantee the parent window's title bar or taskbar, and its width is unaffected.


The two illustration shows what a pop-up window might appear when a parent window in a non-maximized state is in a different position on the screen.

Regardless of which script opens the window, you need to consider UI elements such as display themes, font size, and resolution to adjust the display of the window at design time.

3.4 How to detect whether the browser browsing the site is an Internet Explorer in SP2
You can use Window.navigator.userAgent to detect.
var g_fissp2 = false;
function Browserversion ()
{
G_FISSP2 = (window.navigator.userAgent.indexOf ("SV1")!=-1);
if (G_FISSP2)
{
This browser is Internet Explorer in SP2.
}
Else
{
This browser isn't Internet Explorer in SP2.
}
}

If the user agent string contains "SV1", the browser connected to your site is an Internet Explorer in SP2.

3.5 Other aspects
Windows XP Service Pack 2 (SP2) also has an impact on the installation and download files for ActiveX controls.

In SP2, the mode installation of an ActiveX control is blocked by the InfoBar and prompts the site to require that the control be installed. Users can install ActiveX controls by clicking on the Information Bar. Installing ActiveX controls with pop-up windows and HTML dialog boxes is also blocked.

File download prompts without user clicks or keystrokes are blocked by the InfoBar.

4 Conclusion
In Windows Service Pack 2, Pop-up Blocker blocks windows that are automatically ejected from most scripts except Createpopup (). The return value of the function can be used to determine whether the pop-up window is blocked and take further action.

Appendix:

Createpopup () method

Internet Explorer 5.5 is a new way to support window objects, createpopup (). You can create a pop-up window in the following ways:

var popupobj = Window.createpopup ();
When you create this object, the window is not displayed and you must call its method:

Popupobj.show (Yoffset, xoffset, width, height, referenceobj)
which

Yoffset is the horizontal coordinate offset from the upper-left corner of the screen.
Xoffset is the horizontal coordinate offset from the upper-right corner of the screen.
Width is the size of the pop-up window.
Height is a pop-up window.
Referenceobj is a parameter that replaces the position of the upper-left corner of the screen, and by setting it you can define Yoffset and xoffset relative to its position.

Here is an example of a pop-up window that defines a background and a border:

<script language= "JavaScript" >
<!--
var opopup = Window.createpopup ();
var opopupbody = oPopup.document.body;
OPopupBody.style.backgroundColor = "Magenta";
OPopupBody.style.border = "Solid blue 3px";
opopupbody.innerhtml = "Click outside <B>popup</B> to close."
Opopup.show (+, document.body, M);
-->
</SCRIPT>

Reference documentation on CREATEPOPUP () on MSDN: http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/createpopup.asp

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.