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?
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?
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>
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/
try this using JQuery
$('#yourCotrolId').on('click', function() {
window.open('yourLink','...','width=1080 height=640')
});
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')
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');
.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')
;