Pri*_*nan 10 html iframe firefox struts2 download
我用a <iframe>来显示文本文件:
<div class="document-view">
<img src="img/302.GIF" />
</div>
$(window).load(function () {
<s:if test="extention.equalsIgnoreCase('txt')">
element = '<iframe class="iframe" src="/dmsrepo/<s:property value="docLocation"/>" />';
</s:if>
$('.document-view').html(element);
});
Run Code Online (Sandbox Code Playgroud)
当我在浏览器中检查元素时,我可以看到文件位置.
<iframe class="iframe" src="/dmsrepo/Legal Doc Type/LegalDocType_123456789_1.0.txt" />
Run Code Online (Sandbox Code Playgroud)
但是文本文件正在Chrome,Firefox和IE中下载.
如何解决这个问题?
编辑:你可以重现以下小提琴中的行为,这只会奇怪地影响Firefox,因为第一个页面加载后的每个页面加载.
只需打开页面,然后按Run.
注意:如果激活Firebug Net模块,它也会影响第一次加载.
因为浏览器只能识别html。将文件扩展名更改为 .html
或使用服务器端语言(如 php)并使用 file_get_contents() 函数,您可以将文本文件显示到浏览器。
这是文件的问题。它的格式不是 html。因为它在读取的文件末尾有一些特殊的 unicode (例如)字符。如果文本响应有这样的特殊字符。它无法将响应解析为嵌入 iframe 中的 html。
你可以检查这个例子:
<iframe src='http://humanstxt.org/humans.txt' /> </iframe> Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9192 次 |
| 最近记录: |