I need some help here...
Anyone knows how to solve this?: /
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('');
});
$('#ajax').on('click', function() {
$.ajax({
type: 'POST',
url: '#',
traditional: true,
success: function() {
launch('');
}
});
});
});
})(jQuery);
Thanks!
I need some help here...
Anyone knows how to solve this?: http://jsfiddle/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.');
});
$('#ajax').on('click', function() {
$.ajax({
type: 'POST',
url: '#',
traditional: true,
success: function() {
launch('http://www.google.');
}
});
});
});
})(jQuery);
Thanks!
Share Improve this question edited Jan 22, 2013 at 12:03 Prisoner 27.7k11 gold badges76 silver badges103 bronze badges asked Jan 22, 2013 at 12:03 Marcos EsperónMarcos Esperón 911 silver badge2 bronze badges 2- What are you trying to achieve with this, it looks like a horrible hack. – Ja͢ck Commented Jan 22, 2013 at 12:48
- Any update on this? We are experiencing the same problem. – Hudson Atwell Commented Mar 6, 2013 at 18:40
1 Answer
Reset to default 4Its 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.')}, 10);
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745664135a4639021.html
评论列表(0条)