I have very simple code
$('.opennewwindow').click(function(e) {
e.preventDefault();
window.open("http://www.stackoverflow.com")
/*alert('its works');*/
});
<button class="opennewwindow" value="somevalue">Open new window!</button>
Unfortunately, the code does not work (the function calls, but not open.window). Errors dont appear anywya.
I tried like this too:
$('.opennewwindow').click(function(e) {
e.preventDefault();
myWin = window.open("http://www.stackoverflow.com");
myWin.focus();
});
and following error TypeError: myWin is undefined
.
I used a $(document).ready()
etc. but same effect.
The clue is that on my website I have a ajax scripts. This button and function is also loaded by ajax.
Anyone know why this is not working?