1

我想通過iframe傳輸發送包含文件和一些文本字段的發佈請求。IE9 SCRIPT5訪問被拒絕

(jQuery的文件uload + jquery.iframe運輸)

http: //192.168.1.36:3001/index.html主要頁面的URL。請求網址是http: //192.168.1.36:3001/api/upload

我已經閱讀: 1 2 3 4 5 6 7

等問題。

其他信息:

browser: ie 9.0.8112.16421 

headers of /index.html: 

Cache-Control:no-cache 
Cache-Control:public, must-revalidate, proxy-revalidate 
Connection:keep-alive 
Content-Encoding:gzip 
Content-Type:text/html 
Date:Thu, 25 Sep 2014 19:34:41 GMT 
Expires:Thu, 25 Sep 2014 19:34:40 GMT 
Last-Modified:Thu, 25 Sep 2014 19:17:41 GMT 
P3P:CP="NOI ADM DEV PSAi COM NAV OUR OTR STP IND DEM" 
Pragma:public 
Server:nginx/1.6.2 
Transfer-Encoding:chunked 
Vary:Accept-Encoding 

domain in iframe is 192.168.1.36, domain in main page is same (192.168.1.36) 

"SCRIPT5 Access denied" in "form[0].submit()"。我替換了"form.submit()" to "form[0].submit()"

此外我試圖添加到窗體一個特殊的提交按鈕,並試圖觸發('點擊')。不起作用。

有沒有可能?

感謝

+0

你試圖讓父頁面的一些JS代碼提交表單中的iframe子頁面? – 2014-09-25 19:56:23

+0

@MarcB我試圖通過iframe傳輸從主頁面發送ajax請求。你是否閱讀並理解這個問題? – 2014-09-25 20:00:19

+0

**你的問題中的NOWHERE **你曾經提到過「ajax」,並且沒有「iframe傳輸」這樣的東西。 – 2014-09-25 20:01:19

回答

2

@約翰,

當你寫道:

我也嘗試添加到窗體一個特殊的提交按鈕,並試圖觸發( '點擊')。不起作用。

這是否意味着您試圖使用除<input type="file">元素以外的元素來觸發文件瀏覽?例如。試圖通過隱藏文件輸入元素來設置瀏覽按鈕的樣式?

如果是這樣,SCRIPT5錯誤是因爲IE9認爲它是安全的,試圖阻止用戶未啓動上傳。

解決方案: 如果你的風格的文件輸入元素爲visibility: hidden;,而不是display: none,並且使用一個標籤發起的行動,它會奏效。 您可以根據需要設計標籤樣式,它可以完成您想要的所有功能(我無法使用它來與鍵盤焦點& 輸入鍵)。

例如以下爲我工作:

<label class="my-label-button-style"> 
    <input type="file" class="my-ie9-hidden-file-input"/> 
    Click me 
</label> 

和CSS:

.my-ie9-hidden-file-input { 
    visibility: hidden; 
    position: absolute; 
    width: 1px; 
    height: 1px; 
}