Why this button works in IE but not in Firefox?

2019-09-07 07:56发布

问题:

I have strange issue and I don't know how to fix. This button works perfectly in IE , but not in Firefox. This is the HTML code:

<div class="divbutonSave" onclick="Save()" style="float: right;">
<span>Save</span>
</div>

And this is the Javascript code:

 function Save() {
var poz = '1';
var rowCount = dataTable.rows.length;
var ala0 = "";
for (var i = 1; i < rowCount; i++) {
var c = document.getElementById("chk " + i);
if (c.checked == 1)
ala0 += dataTable.rows[i].cells[1].innerText + "^";
var ala = ala0.substring(0, ala0.length - 1);
}
$.ajax({
url: '/ProjectAdministrator/ProjectAdministratorProject/Partners',
data: { pozActivity: poz, listapart: ala },
dataType: "Json",
type: "POST",
error: function () {
alert("Error");
},
success: function (data) {
window.close();
}
});
} 

Any suggestions? Thanks in advance

回答1:

I'd suggest if you want a button, you should use a button in your markup, rather than a div. That way your markup will represent what it means, and it may have the side effect of working properly too.