Jump to content



Welcome to KnowledgeSutra - Dear Guest , Please Register here to get Your own website. - Ask a Question / Express Opinion / Reply w/o Sign-Up!
- - - - -

Access Local File Using Iframe


4 replies to this topic

#1 rasheed_rgda@hotmail.com

    Newbie

  • Kontributors
  • Pip
  • 2 posts

Posted 23 March 2010 - 04:30 PM

Hi all,
I am using Iframe in the jsp page to display the local file in the file system
I am using following tag to display the file in the jsp page.
<iframe  src=file:///c:/modify.html width="40" height="80">
It displays modify.html file properly in the IE browser , but its not showing in the Firefox browser.

In Firefox , the following error is getting displayed .

Quote

Security Error: Content at http://localhost:8080/Struts2Example6/ may not load or link to file:///C:modify.htm.

After googling, I found that I need add one users.js file in the following location
C:\Documents ndSettings\Rasheed\ApplicationData\Mozilla\Firefox\Profiles\9wapkhj3.default
The content of users.js is as follows:
user_pref("capability.policy.localfilelinks.checkloaduri.enabled",  "allAccess");
user_pref("capability.policy.localfilelinks.sites","http://localhost:8080/Struts2Example6")  
user_pref("capability.policy.policynames",  "localfilelinks");
Even then, its not showing the it in the Firefox browser.

Please help me to fix this.
Thanks

#2 BuffaloHelp

    Sterling Archer

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 4,088 posts
  • Gender:Male
  • myCENT:50.18

Posted 24 March 2010 - 05:26 PM

Is there a particular reason why you have to show local file with your webpage? Is this for a development purpose?

Besides the obvious security issue, there are many reasons why web browser cannot display local file without some extra programs installed.

The easiest way to include local file to your website is run a webserver (xampp, wamp, apache, IIS) on your local machine and then include as

http://localhost/folder/file.ext

Because, the inclusion of local file on the internet is useless in the way that the file name, location must be the same throughout every visitor. Otherwise, the inclusion is just for your sake. And that means, it's easier to run a private webserver at the end and then use the inclusion.

#3 k_nitin_r

    Grand Imperial Poobah

  • Kontributors
  • PipPipPipPipPipPipPipPipPipPipPip
  • 1,114 posts
  • Gender:Male
  • Location:Dubai
  • myCENT:50.55

Posted 26 March 2010 - 04:11 PM

Hi!

@rasheed_rgda

Displaying a file from the computer system on which the browser runs is not recommended for two reasons:
1. The file may not be present on the computer
2. The browser prevents you from doing so, especially of the JSP script is running from a public web server instead of localhost

You might want to host the file that you want to place into the IFrame in the directory from which your web server serves content, as BuffaloHelp has suggested in his reply to your post. If you place your content within the same folder path as the JSP file, you can get away with simply using the filename instead of having to specify the entire file path. As a general guideline, try to use filenames for references, and if that isn't possible switch to relative URLs, and if that route is a no-go too then using absolute URLs. Absolute URLs break when you have to move to a different domain. Relative URLs work pretty well and you can easily setup a test server to check your changes before you push your changes across to a live web server. Using filenames is simpler still because it shortens the string and you have less typing to do ;-)

#4 darko100

    Advanced Member

  • Kontributors
  • PipPipPipPipPipPipPip
  • 117 posts
  • Gender:Male
  • myCENT:31.51

Posted 23 April 2011 - 05:38 PM

That is the security model of the browser , not only Firefox , all modern browser will not allow you to include a local file. There is no reason why to do that.

If a user opens your page and doesn't have that file? Thats for sure , because not everyone is using C: as a OS disk , or using Windows and having a "partition" like C: or D: :)

You can iframe any internet webpage or a server file which is in the directory on your server. But websites like facebook and twitter are using scripts that disables embedding sites. However , you can include your own page , like including login.php on your site , so users can login without going to login.php

And yes , it needs to work if you follow http://kb.mozillazin...es_don%27t_work this tutorial

#5 Guest_Marek_*

  • Guests

Posted 10 November 2011 - 01:22 PM

View Postdarko100, on 23 April 2011 - 05:38 PM, said:

That is the security model of the browser , not only Firefox , all modern browser will not allow you to include a local file. There is no reason why to do that.

Browsers as IE, Opera, Chrome (all in last version) are able to open local files in iframe.
And yes, there is good reason, why to do that - for example: a little complex off-line version of a web-base application (CD, DVD...).

View Postdarko100, on 23 April 2011 - 05:38 PM, said:

If a user opens your page and doesn't have that file? Thats for sure , because not everyone is using C: as a OS disk , or using Windows and having a "partition" like C: or D: :)
Why you want use ablolute path? You can use relative path.

You can iframe any internet webpage or a server file which is in the directory on your server. But websites like facebook and twitter are using scripts that disables embedding sites. However , you can include your own page , like including login.php on your site , so users can login without going to login.php

View Postdarko100, on 23 April 2011 - 05:38 PM, said:

And yes , it needs to work if you follow http://kb.mozillazin...es_don%27t_work this tutorial

:-) You must be joking... it is the worst solution.




Reply to this topic


This post will need approval from a moderator before this post is shown.

  


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users