2011-01-19 62 views
1

我有一個簡單的html頁面來打開一個基於OPTION列表的不同的HTML使用ON CHANGE來觸發WINDOW.OPEN,在IE8中,我得到一個窗口出現並消失真實當我選擇May10時,速度很快。 當我選擇SFAA或谷歌,它工作正常,使用A HREF打開xls文件也可以。ie8 window.open xls不工作

我在Firefox(3.6.13)中試試這個,Chrome和一切正常。

`<select name="target" 
     onChange="if (this.options[this.selectedIndex].value != '') 
     {window.open(this.options[this.selectedIndex].value,'_blank');};" > 
     <option VALUE="" style="color:#000000;">Select</option> 
     <option VALUE="http://www.google.com">google</option> 
     <option VALUE="../May10.xls">May 10</option> 
     <option value="../sfaa.pdf">SFAA</option> 
</select>` 

window.open(this.options [this.selectedIndex] .value,'_ blank');在IE8中不起作用。 '_parent'或'_self'也適用於IE8。 一切工作正常在Firefox和谷歌鉻

回答

4

我整個網絡上的解決方案來了,更換JS調用

window.open(this.options[this.selectedIndex].value,'_blank'); 

var w = window.open(this.options[this.selectedIndex].value,'_blank');w.location.href = this.options[this.selectedIndex].value; 

它炒鍋兩個IE8和Firefox的罰款。

+0

像魅力一樣工作:) – 2013-01-23 13:32:03

0

你可能張貼的窗口或信息消息的屏幕截圖或描述出現?

...因爲當我嘗試在IE8/Windows 7/MBP上時,它對我來說工作正常。

我所做的是我製作了一個您發佈的代碼的html文件,當我在IE8中選擇我自己的xls文件(保存在Excel 2007中)時,它提示我用對話框打開/保存/取消文件就像下載附件時一樣),我可以選擇查看它,並且文檔成功打開。

也許還可以檢查您提供的相對路徑,指定的文件是否存在並且沒有損壞,並且您的計算機編程爲默認使用Excel運行xls文件?

+0

我很抱歉,window.open參數應該是'_blank'window.open(this.options [this.selectedIndex] .value,'_ blank');不起作用。 '_parent'或'_self'也適用於我。我會更新我的問題。 – huahua 2011-01-20 14:25:01

0

你在XLS文件的HTTP響應中看到了什麼標題(例如看看Fiddler)?

如果無法下載(例如,由於沒有緩存頭),那麼您可能會看到像這樣的不良行爲。

http://blogs.msdn.com/b/ieinternals/archive/2009/10/03/internet-explorer-cannot-download-over-https-when-no-cache.aspx

+0

window.open(this.options [this.selectedIndex] .value,'_ blank');不起作用。但使用'_parent'或'_self'而不是'_blank'可以正常工作。打開或下載沒有問題。我也沒有任何來自IE8的警告提醒。 – huahua 2011-01-20 17:37:19