JQuery 对话框 / submit() 在 IE8 中不起作用

JQuery dialog / submit() not working in IE8

本文关键字:IE8 不起作用 对话框 submit JQuery      更新时间:2023-09-26

适用于除IE8以外的任何地方。提交永远不会触发。我尝试取出对话框并离开提交,但在IE8中仍然没有任何反应。

Javascript:

$(function () {
    $("#fileUpload").click(function () {
        $("#fileButton").click();
    });
});
$(function () {
    $("#fileButton").change(function () {
        $("#dialogUploading").dialog({
            dialogClass: 'no-close',
            modal:true,
            async:true
        });
        $("#formSubmit").submit();
    });
});

.HTML:

        using (Html.BeginForm("ReferralUpload", "ReferralNetwork", FormMethod.Post, new { enctype = "multipart/form-data", id = "formSubmit", style = "display:inline" }))
        {
            <input type="file" id="fileButton" name="fileButton" style="display:none" />
            <button type="button" id="fileUpload" style="width:250px;">Upload Referrals</button>
        }

有什么想法吗?谢谢!

您可以尝试将$("#fileButton").change(function () {更改为$("#fileButton").change(function (e) {,看看这是否有区别吗? 我认为IE需要传递事件才能快乐。

哦,对$("#fileUpload").click(function () {做同样的事情$("#fileUpload").click(function (e) {

确保你使用的是正确版本的jQuery。版本 2 及更高版本与 IE8 不兼容。

http://jquery.com/browser-support/

经过进一步的研究,我发现它无法完成 jQuery:模拟对 的点击在 Firefox 中不起作用?并非没有一些黑客行为。在 IE8 中,无法以编程方式单击文件输入,否则无法提交。一个技巧是将不透明度设置为零并在按钮上显示图像:http://www.quirksmode.org/dom/inputfile.html