1

I use this code:

<iframe src="@HttpContext.Current.Server.MapPath("~/Temp/sample.docx")" height="800" scrolling="no" align="top" frameborder="0" >
  <p>Your browser does not support iframes.</p>
</iframe>

but I get this error:

The address wasn't understood 

Firefox doesn't know how to open this address, because the protocol (d) isn't associated with any program.

You might need to install other software to open this address.

Chris O'Kelly
  • 1,863
  • 2
  • 18
  • 35
gel
  • 11
  • 2
  • 6
  • is the file local to the server or local to the client browser? I am kind of assuming server based on your syntax, but whatever language that is (ASP.Net maybe?), you may want to tag your question for it also (it's not javascript) – Chris O'Kelly Nov 22 '12 at 06:06
  • Are you using a serverside language to generate the stuff in the `src` attribute? – Blender Nov 22 '12 at 06:06
  • as far as seems to be suggested by [this answer](http://stackoverflow.com/questions/10378965/firefox-doesnt-load-local-file-in-iframe), this is not possible. Consider uploading the file to your webserver and linking to it thus – Chris O'Kelly Nov 22 '12 at 06:10
  • yes sorry, it is server based. should I use – gel Nov 22 '12 at 06:11
  • @gel do you mean that the file is server based or you are using server based code (well... you are. I'm just making sure you know that you are, that code will be absolutely no help if thats the html that reaches the client)? – Chris O'Kelly Nov 22 '12 at 06:13

1 Answers1

1

If you are using ASP.NET MVC, then src must be written like this:

src="@Url.Content("/Temp/sample.docx")"
karaxuna
  • 26,752
  • 13
  • 82
  • 117
  • src="@Url.Content("/Temp/sample.docx")" - this one let me download the file but i only needed it to display on my iframe Thanks :) – gel Nov 22 '12 at 06:16
  • 1
    @gel this is browser implementation. If the browser has compatible plugins and has been set to show that type of content rather than download it, it will. You cannot force this with your code unless you get a lot more complex, eg, the Alfresco CMS (and other CMS's I believe) implement this by using converters to change a word document/pdf/whatever else into flash, which is then displayed on the page. Even in this case, it would only work with the user having flash installed – Chris O'Kelly Nov 22 '12 at 06:26
  • 1
    that's other question, see http://stackoverflow.com/questions/3162989/docx-file-doesnt-open-in-browser-with-content-disposition-inline-in-ie-8 – karaxuna Nov 22 '12 at 06:26
  • Ive tried to convert the word doc to html file i can now browse file:///D:/Projects/sample.htm to different browser but still doesn't work inside iframe. It displays blank. – gel Nov 22 '12 at 09:29
  • If you want to browse html file, you should load it. load html – karaxuna Nov 22 '12 at 10:13