我有一个表格:
<form accept-charset="UTF-8" action="/back/pages/22?locale=fr" class="form-horizontal page-form" enctype="multipart/form-data" id="edit_page_22" method="post" target="_blank"><div style="margin:0;padding:0;display:inline"><input name="utf8" type="hidden" value="✓">
<p><a href="#" id="no_window">Submit</a></p>
<p><a href="#" id="new_window">Submit & _blank</a></p>
</form>
并附上一个脚本:
$(document).ready(function() {
var page_form;
page_form = {
elem: $('form.page-form'),
rand_action: function() {
var action;
action = this.elem.attr('action');
return this.elem.attr('action', action + '&count=' + Math.random() * 1000);
},
submit_blank: function() {
this.elem.attr('target', '_blank');
$('<input>').attr({
type: 'hidden',
id: 'input_new_window',
name: 'edit_redirect',
value: 'true'
}).appendTo(this.elem);
return this.elem.submit();
},
submit: function() {
this.elem.attr('target', '_self');
$('#input_new_window').remove();
return this.elem.submit();
}
};
$("#new_window").click(function(event) {
event.preventDefault();
page_form.submit_blank();
page_form.rand_action();
return page_form.submit();
});
$("#no_window").click(function(event) {
event.preventDefault();
return page_form.submit();
});
});
它在 FF 上运行良好但在 Chrome 上运行良好,知道为什么吗?