‘
i have a javascript function that im trying to trigger and run. here is what i came up so far, but something seems to be wrong:
<script type="text/javascript">
$("#fb_login").click(function(){
<!--
function myPopup2() {
window.open( "http://www.page.html", "myWindow",
"status = 1, height = 400, width = 400, resizable = 0" )
}
//-->
});
$("#fb_login").click();
</script>
<p id="fb_login" onclick="myPopup2()"></p>
any ideas?
thanks
It’s simpler than you think 🙂
This will bind the popup to a click on the
#fb_loginelement. However, if you are trying to run it at once, then just:or simply
is sufficient.
However, you should be aware that
window.openwithout user input (like a click) will trigger a popup-preventer in all modern browsers. Some will give a warning, others will ignore your function call altogether, and you programmatically callingclick()won’t change that.