Popup without user action?

泄露秘密 提交于 2020-01-25 06:13:40

问题


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?


回答1:


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>



回答2:


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/




回答3:


try this using JQuery

        $('#yourCotrolId').on('click', function() {
    window.open('yourLink','...','width=1080 height=640')
});



回答4:


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')



回答5:


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');



回答6:


.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');



来源:https://stackoverflow.com/questions/17920758/popup-without-user-action

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!