The example in this article describes how to use JS to open a new window to prevent it from being blocked by the browser. Share it with everyone for your reference. The specific analysis is as follows:
Opening a new window using the traditional window.open() method will be blocked by the browser. So, how can we make JS open a new window without being blocked by the browser? In fact, there are still ways. Here we will analyze how to solve this problem
I have also encountered such a problem recently, so I will share with you how to pop up a new window. Everyone is welcome to add...
The first method is to use the window.open() method of native javascript (which will be automatically blocked by browsing in most cases)
The second method is to simulate form submission. The principle is to specify the action of the form as the URL address you want to open, and the target is set to "_blank"
However, the method of simulating form submission may also be blocked...
The third type, simulated hyperlink () being clicked
When you press a button and want to open a new tab, you can simulate the link being pressed and then open the link.
But in jQuery, using a.click(), a.trigger('click'), etc. will not cause the link's default event to be executed.
The following code simulates generating a link click event, and then executes the event that opens the link by default.
However, one thing worth noting is: for IE browser, only IE9 or above supports the document.createEvent function, so if the following code is executed in IE, IE9 or above is required
The fourth method is to use the browser’s bubbling event (reprinted)
1). First of all, let’s talk about the final effect, which is to use “A” to contain the element you want to trigger the pop-up window. The original click event should return the URL of the pop-up window, which corresponds to this sentence:
I hope this article will be helpful to everyone’s JavaScript programming design.