Jump to content
xisto Community
rasheed_rgda@hotmail.com

Access Local File Using Iframe Iframe with local file is not getting displayed in the jsp page.

Recommended Posts

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 .

Security Error: Content at 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

Share this post


Link to post
Share on other sites

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

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.

Share this post


Link to post
Share on other sites

Hi!@rasheed_rgdaDisplaying 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 computer2. The browser prevents you from doing so, especially of the JSP script is running from a public web server instead of localhostYou 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 ;-)

Share this post


Link to post
Share on other sites

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.phpAnd yes , it needs to work if you follow http://kb.mozillazine.org/Links_to_local_pages_don%27t_work this tutorial

Share this post


Link to post
Share on other sites

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...).

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

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


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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.