I need some help here...
Anyone knows how to solve this?: http://jsfiddle.net/Q3BfC/5/
When I submit a form with target="_blank" by defaults opens a new tab. But if try to do it after an ajax request, the forms opens a popup window.
(function($) {
jQuery(document).ready(function() {
var launch = function(p_url) {
var form = $('<form />').hide();
form.attr({'action': p_url, 'target': '_blank'});
form.appendTo(document.body);
form.submit();
form.remove();
delete form;
};
$('#normal').on('click', function() {
launch('http://www.google.com');
});
$('#ajax').on('click', function() {
$.ajax({
type: 'POST',
url: '#',
traditional: true,
success: function() {
launch('http://www.google.com');
}
});
});
});
})(jQuery);
Thanks!
Its not trying to open it as a popup but its blocked by the popup blocker cause open something with target:_blank
in a new tab is only allowed when it is the direct result of an user input, like click or keydown.
You will get the same result when you try to open it in a setTimeout:
setTimeout(function() {launch('http://www.google.com')}, 10);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With