Preventing “SCRIPT5: Access is denied” error in IE

后端 未结 3 1914
梦毁少年i
梦毁少年i 2020-12-03 09:27

Scenario: Page A on A.com that has an IFrame containing Page B on B.com. Page B uses jQuery 1.10.1 and does not need to communicate with Page A.

Regardless

3条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-03 10:08

    Ok I Found the same problem and fixed it with the weirdest and most horrible solution ever.

    I'm trying to use an image to popup the file upload dialog, then do an automatic form submit on the change event. I had resigned my self that in IE the users were going to have to click an image to do the post. I placed the image on the form (like i have in several places on the site. This to generated the access denied error, In shock I clicked it again and Yep got the error. On the third click it worked. So I tried it again with the same results first two clicks error and the third worked. And teh simple Javascript code that is ugly as home made soap but now works is

    var files= document.getElementById("newfiles");
    files.onchange = addFiles;
    
    function addFiles() {
        try {
            $("#fileupload").submit();
        } catch (e) {
            try {
                $("#fileupload").submit();
            } catch (e) {
                try {
                    $("#fileupload").submit();
                } catch (e) {
                    alert(e);
                }
            }
        }
    };
    

提交回复
热议问题