window.open () post-intercept analysis

Source: Internet
Author: User

Objective:
This article is only a few of the records and summaries that have been encountered in your personal work and may be meaningless.


Event review:

In development, PM requires that multiple links be entered in a single page and then opened in a new window with a single click, so the idea is to use window.open to implement it, but the test finds it intercepted.

Analysis:

About window.open user Many predecessors have written related articles, it is not introduced here, see window.open usage

The following tests were done for different browsers


1. The user clicks the event, triggers the opening of a new window

The user clicks the event to trigger a new window for example:

Obj.onclick=function () {

window.open (URL);

}

A new window opens through a user event, which opens a new window that the browser will think is the user's own needs, most browsers will not intercept

Currently testing several user events, only click and Dbclick are not blocked by the browser

Window blocking is not just about the browser kernel, so there are tests on native IE and several common IE kernel browsers.

Event: Click,dbclick

Non-blocking browsers are: Chrome,ff,ie 6.0-10.0,safari,opera,360 browser

Interception: Sogou Browser

Event: Mouseover,mousemove,mouseout,scroll, etc.

No interception: None

Intercept: Chrome,ff,ie 6.0-10.0,safari,opera,360 Browser

2. The user clicks the event, triggers to open several new windows

Click once to successfully open multiple windows in the browser: ff,360 browser, Safari

Click once to open the first window, behind the window blocker browser: Chrome,ie 6.0-10.0,opera

3.Javascript Auto Trigger open window

Such as:

SetTimeout (function () {window.open (' http://www.baidu.com ')},1000)

Or the AJAX request succeeds after the execution

$obj. Click (function () {

$.ajax ({

Sucss:function (data) {

if (data) {

window.open (' http://www.baidu.com ')

}

}

})

})

Blocked browsers: Test several browsers to intercept

Solution:

1. For Ajax after the return to open a new window, you can open a blank window after the user clicks, and then return to the success of the blank window a URL, so that it will not be blocked

$obj. Click (function () {

var newtab=window.open (' About:blank ');

$.ajax ({

Sucss:function (data) {

if (data) {

window.open (' http://www.baidu.com ');

Newtab.location.href= "http://www.baidu.com";

}

}

})

})

2. The script triggers the open new window itself

See online a lot of said new a tag, analog Click, tested, invalid, please Daniel guide

window.open () post-intercept analysis

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.