Popup without user action?

2019-08-07 15:06发布

How is this site triggering its popup while bypassing Chrome's pop-up blocker?

http://undertexter.se/

I thought pop-up blockers only allowed window.open if it was triggered by a user action but that's not the case here so how are they doing it?

6条回答
Summer. ? 凉城
2楼-- · 2019-08-07 15:20

You could use the .trigger method for simulating an user action:

<a href="javascript:" onClick="window.open('example.html','example','width=200,height=200');">Click</a>
$('a').trigger('click');
查看更多
别忘想泡老子
3楼-- · 2019-08-07 15:21

.trigger() can not be used to mimc such native browser events, you can use .simulate() from simulate.js to mimic such events.

include simulate.js in your file and use,

$('a').simulate('click');

查看更多
Root(大扎)
4楼-- · 2019-08-07 15:29

Tested on my own server, This opens up http://google.com in a new (standalone) window in Chromium 28 on Ubuntu 12.04. Adblock is active.

<script type="text/javascript">
document.addEventListener('click', function() {
    window.open('http://google.com','...','width=1080 height=640')
})
</script>
查看更多
Summer. ? 凉城
5楼-- · 2019-08-07 15:35

I figured out that there is an popup opening in chrome if you visit the Website first time (empty cache) and click somewhere on the document. After a refresh and a click on it again nothing will happen if cache wasn't removed.

So lets start the game of reverse engineering...

Took the script from http://undertexter.se/ and startet refuscation.

After a few steps I got the following code and I think this is not planned by browser manufactures to support something like this.

Now I wish you a lot of luck to use that for your own but I think it's evil.

Look on js fiddle for the result: Its the reverse of:

http://www.wigetmedia.com/tags/undertexter.se.js

http://jsfiddle.net/W9BdS/

查看更多
女痞
6楼-- · 2019-08-07 15:38

try this using JQuery

        $('#yourCotrolId').on('click', function() {
    window.open('yourLink','...','width=1080 height=640')
});
查看更多
迷人小祖宗
7楼-- · 2019-08-07 15:46

window.open is blocked by modern browsers when called not in a click event handler.

I faced this myself while using Rails' format.js responses and wrote a small plugin that makes showing JS popups as simple as calling window.open():

Popup("<div>Hello world</div>").show('up')
查看更多
登录 后发表回答