How to stop embedded HTML files from downloading?

大城市里の小女人 提交于 2020-01-14 06:08:05

问题


I have a .html document that I need in an <iframe> tag. Let's say it is called FILE.html and is hosted at http://files.net/FILE.html.

So, I write the iframe tag as such: <iframe src="http://files.net/FILE.html"></iframe>

Instead of the iframe appearing as a nice little box and rendering the html in FILE.html, it instead opens File Explorer and prompts the user to download FILE.html. I don't want them to download it, I just want them to see it rendered on their screen.

So is there a way for me to format it such that the html renders and doesn't download? Can I change the FILE.html, or change the iframe tag, or upload it in a different way?


回答1:


Something about the way that file is being served is telling the browser that it isn't an HTML file that can be displayed. This is probably because its Content-Type header is incorrect, but may also be because the file is being served with a Content-Disposition header that instructs the browser to download it.

Assuming that you have access to the server that this file is being served from, you will need to configure it to use the correct headers. There is no way to override these headers in a frame.



来源:https://stackoverflow.com/questions/34445215/how-to-stop-embedded-html-files-from-downloading

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!