js~ Demo form opens in a new window to avoid ad blocking

Source: Internet
Author: User

Speaking of ad interception, this should be a feature of the browser, it will be the window generated by default window.open to an ad, it is blocked, but sometimes, this is not what we want, sometimes we just need it to pop up a new window on the client's browser to show the data processing updates, such as , a preview feature that creates a product that needs to save the data and then display the latest information in a new window is not a small requirement, and most people do it using window.open to pop the window, but it's not a good way!

New way to go.

We know that the form submission can actually respond to the results of the post to a new window, we are using the form of this nature, in JS to forge a form, to realize the new window display data function

       // masquerading as a form submitted in a new window        function newwinurl (URL) {            var f=document.createelement ("form");            F.setattribute ("action" , URL);            F.setattribute ("method", ' Get ' );            F.setattribute ("target", ' _black ' );            Document.body.appendChild (f)            f.submit ();        

When the program calls it, there may be code like this

       // preview function        $ ("#do"). Click (function  () {            $ajax ({                "get",                Data: {},                function  (data) {                    + data);});})        ;

0, it's ready for testing.

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.