Home >Web Front-end >JS Tutorial >Simulating a user's click to pop up a new page will not be intercepted by the browser_javascript skills

Simulating a user's click to pop up a new page will not be intercepted by the browser_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:52:551330browse

I believe that friends who have used window.open have encountered situations where the page cannot be popped up due to being blocked by the browser. Let's change our thinking and ask, under what circumstances will the pop-up of a new page not be blocked by the browser? For example, the tag will not; then we only need to simulate the user to actively click on the tag and there will be no interception problem.

First define the HTML tags:

Copy the code The code is as follows:


< ;input type="button" value="Click me to pop up a new page" onclick="targetClick()" />

Then assign a value to the tag in JS and trigger it Click event:
Copy code The code is as follows:

function targetClick() {
$ ("#alink").attr("href", "http://www.163.com");
$("#spanlink").click();
return false;
}

OK, now the page will pop up smoothly.
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