Js Implementation of window. open not blocked solution summary, jswindow. open

Source: Internet
Author: User

Js Implementation of window. open not blocked solution summary, jswindow. open

This article describes how to implement window. open without blocking in js. Share it with you for your reference. The specific analysis is as follows:

I. Problems:

In the process of processing the page ajax request today, if you want to open a new page after the request is implemented, you want to implement it through js window. open, but it is finally intercepted by the browser.

Ii. Analysis:

Is there a solution for Google search? Some say it can be achieved by creating a tag and simulating a click. However, the test results cannot be achieved, so it is intercepted by the browser.
Finally, we found a compromise to enable the new page to open, but there is no a tag for direct traffic to the new page.

Iii. Implementation Code:

Copy codeThe Code is as follows: $ obj. click (function (){
Var newTab = window. open ('about: blank ');
$. Ajax ({
Success: function (data ){
If (data ){
// Window. open ('HTTP: // www.bkjia.com ');
NewTab. location. href = "http://www.bkjia.com ";
}
}
})
})
Other methods:

Copy codeThe Code is as follows: <script type = "text/javascript">
<! --
$ (
Function ()
{
// Method 1
Window. showModalDialog ("http://www.bkjia.com /");
Window. showModalDialog ("http://www.bkjia.com /");
 

// Method 2
Var aa = window. open ();
SetTimeout (function (){
Aa. location = "http://www.bkjia.com ";
},100 );
 

Var B = window. open ();
SetTimeout (function (){
B. location = "http://www.bkjia.com ";
},200 );
 

Var c = window. open ();
SetTimeout (function (){
C. location = "http://www.bkjia.com ";
},300 );
 

Var d = window. open ();
SetTimeout (function (){
D. location = "http://www.bkjia.com ";
},400 );
 

Var ee = window. open ();
SetTimeout (function (){
Ee. location = "http://www.bkjia.com ";
},500 );
 

Var f = window. open ();
SetTimeout (function (){
F. location = "http://www.bkjia.com ";
},600 );
 

Var g = window. open ();
SetTimeout (function (){
G. location = "http://www.bkjia.com ";
},700 );
 

Var h = window. open ();
SetTimeout (function (){
H. location = "http://www.bkjia.com ";
},800 );
 

Var I = window. open ();
SetTimeout (function (){
I. location = "http://www.bkjia.com ";
},900 );
 

Var j = window. open ();
SetTimeout (function (){
J. location = "http://www.bkjia.com ";
},1000 );
 

// Method 3
Var a = $ ("<a href = 'HTTP: // www.bkjia.com 'target =' _ blank '> Apple </a>"). get (0 );
Var e = document. createEvent ('mouseevents ');
E. initEvent ('click', true, true );
A. dispatchEvent (e );
 

Var a = $ ("<a href = 'HTTP: // www.bkjia.com 'target =' _ blank '> Apple </a>"). get (0 );
Var e = document. createEvent ('mouseevents ');
E. initEvent ('click', true, true );
A. dispatchEvent (e );
}
 
);
// -->
</Script>

I hope this article will help you with javascript-based web programming.


Can I replace windowopen js functions? Or is not blocked.

There is a very beautiful jquery plug-in called boxy. js

As you can see, the principle is to dynamically load an iframe In the div layer and then load your page.

For button buttons, how does js achieve new page Jump? Besides the windowopen () method (including this derivative method, It will be intercepted by the browser)

How do you implement it? Why do we have to use a Button? Why is it better for you to use a hyperlink?

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.