Home >Web Front-end >JS Tutorial >Summary of solutions to implement window.open without being intercepted using js_javascript skills

Summary of solutions to implement window.open without being intercepted using js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 16:32:371190browse

The example in this article describes the js solution to implement window.open without being intercepted. Share it with everyone for your reference. The specific analysis is as follows:

1. Question:

Today, while processing the page ajax request, I wanted to open a new page after the request, so I thought of using js window.open to achieve it, but it was eventually intercepted by the browser.

2. Analysis:

Search Google for any solutions. Some say it can be achieved by creating a new a tag and simulating clicks. However, the test found that it cannot be achieved and is still blocked by the browser.
Finally, I found a compromise method that can open a new page, but without the effect of direct traffic to the new page like the a tag.

3. Implementation code:

Copy code The code is as follows:
$obj.click(function(){
var newTab=window.open('about:blank');
$.ajax({
success:function(data){
if(data){
//window.open('http://www.jb51.net');
newTab.location.href="http://www.jb51.net";
}
}
})
})

Other methods:

Copy code The code is as follows:

I hope this article will be helpful to everyone’s web programming based on JavaScript.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn