Detecting whether to activate blocking pop-up windows

Source: Internet
Author: User
Keywords function that is this whether

Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall

Whether you think pop-up windows are a modern form of plague, like locusts and Britney Spears ' CDs, the truth is that they've been doing evil for some time. Many web-based applications use pop-up windows to do useless things, ranging from displaying help pages to displaying pictures of different products. Unfortunately, if the client's browser has a plugin that blocks pop-ups and is activated, it is hard for the merchant to use a pop-up window for them.


A viable solution is to fill your site with "pop-up windows for this site, make sure you don't use Pop-up Blocker" messages. But in doing so, it seems unrealistic to want users to not use pop-up windows when browsing your Web pages. All you need to do is check to see if the user has the ability to block pop-up windows so that your site adapts to your browsing needs.

Use a pop-up to block pop-up windows
The way I chose to do this is to try to open a pop-up window. Of course, this means that I have to be very careful in my programming process, because if I do not, there may be an error in the client. With that in mind, I installed the Google Toolbar and encoded the page using a loading event handler (the OnLoad event handler), which detects software that blocks pop-up windows. The results of this are shown in listing a and listing B.

The method shown in listing A is that the Mount event handler (called Setevents) is hit and attempts to open a popupchild.html page displayed in Listing B. This may seem like a good enough way to determine if the pop-up window is working, but it's not always the case. This depends on the blocking feature installed without problems. All we need is to have the child window pop up to display the hello,world! "or something else. This page uses the SetTimeout method to delay the invocation of the Checkchild method; This leaves the pop-up window with a hidden input object that changes the parent window and the time it takes to close itself. Once this work is done, the Checkchild method checks the hidden input object to see if the child window has changed its contents. If its contents have been altered, the popup function will take effect, which means that the customer is not using the interception feature.

The two hardest part of the entire testing process is accessing the hidden input object of the parent window and estimating when the pop-up window is open. The first problem is easily solved by using the Window.opener of the Document Object model. The second part is more difficult, after all, when I use these examples, browsers and servers are on the same machine. So, even if these examples work for me, they might not work for anyone else. A better way must be found.

A better way
One interesting thing about JavaScript is that it's not influenced by browsers and it's relatively consistent. If a condition appears on a browser, it is strange that it is less likely to appear on other browsers. For example, using an object to write a warning code will display "[Object]" in Microsoft's Internet Explorer and "[Object window]" in Mozilla. Another interesting thing is that the above problems only occur after the object is created. You can see the example of Listing C. We need to pay attention to the above problem, because we just check whether the function of blocking pop-up window is turned on, it is just an empty page.

I wrote this code because recently some developers and technical support staff spent three hours in the conference room to solve the problem. The remote client insists that they do not use Pop-up blocker; it was not until everyone was exhausted that they were asked to check the software installed by the customer. Near the end of the list there is a program that adds a cute smiley face to the customer's email. By simply checking, the program does not just have the ability to add a smiley face to an e-mail message, it can also intercept pop-up windows. The user installs this thing without realizing it, which is the problem I want to avoid when I write the code.

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.