开发者

How to open any file in a iframe

开发者 https://www.devze.com 2023-04-05 06:31 出处:网络
i am using a iframe in my web page. I want to open a file c:\\Dir\\SubDir\\xyz.doc inside a iframe.How to do this ? I checked out many sources开发者_运维问答 ,all of them specified to give the source

i am using a iframe in my web page. I want to open a file c:\Dir\SubDir\xyz.doc inside a iframe.How to do this ? I checked out many sources开发者_运维问答 ,all of them specified to give the source of the iframe to the path by adding the code.Its not working for me. Here is my code

iframe1.attributes["src"] ="c:\\Dir\SubDir\xyz.doc"


assuming you want to open a file on the client's computer, you would need to use a file URL, such as "file://c|/Dir/SubDir/xyz.doc". that said, it still may not work correctly for various reasons (probably primarily security-related).

if my assumption is wrong and you want to display a file on the server, you still need to use a URL and not a file path, meaning you'd have to have the file somewhere under the document root: "../Dir/SubDir/xyz.doc" for example.

then there is the strong likelihood that a .doc file will not render correctly on a webpage.


<iframe src="test.doc"></iframe>

above example is working in my environment, cause I put file inside my project folder and access that file from there..

you can not open any file out side of your project folder.... So please keep this in mind.

@jcomeau_ictx is right you cannot open .doc file in browser but yes it will ask you to save file, if you put in iframe..

0

精彩评论

暂无评论...
验证码 换一张
取 消