Home > Web Front-end > JS Tutorial > body text

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

WBOY
Release: 2016-05-16 16:32:37
Original
1146 people have browsed it

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.

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template