We help IT Professionals succeed at work.

want to load a local file off disk as an html page

272 Views
Last Modified: 2010-04-16
when I run the code below I get a permission denied error. I have been trying to change/fix the syntax of the file url but apparently cannot get it right. I need this in a hurry and am trying to avoid spending a lot of time doing a Google for the answer....

function loadmain()
{
  window.location.href='file:///c:\inetpub\wwwroot\MdtMainFrm.htm'
}
 
setTimeout("loadmain()",1000);
Comment
Watch Question

b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
Is this from an Internet page or what type of page (i.e. local, intranet)?  What browser?

Browser security will prevent you from accessing local files if the page is an Internet page.  There are some browser (e.g. some versions of IE) that don't enforce this well but this will definitely be an issue for many browsers.  Local htm files or those that end with .hta have a lower security limit and could probably access the file.

Let me know if you have a question or need more info.

bol

Author

Commented:
It is a local file, in same folder as all of my asp and html pages....based on your comments, I will go look at Internet security settings?

Author

Commented:
are you saying that the syntax looks correct?
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
The syntax looks correct but I very seldom use the file: protocol and it seems that some browsers use a little different syntax (or work better with a different one).  What is the browser you are using?

Why use the file URL if the file is in the folder and on your local webserver?  Is the URL for the main page http: or file: ?

bol
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
Another way to write it which you can try is ...

window.location.href='file:///c:/inetpub/wwwroot/MdtMainFrm.htm'

bol

Author

Commented:
Let me explain what I am trying to accomplish. I have an html/asp app that runs on a laptop that brings up the web app as part of its startup.

I am trying to let the IIS.exe and other aspects of the OS get started so I do not want the browser to have to bother the IIS exe and load the html file as html w/o having the iis have to deal with it. I hope I am explaining this well enough because I kinda inherited this app and am a C++ person by experience and this html stuff is new to me.....

Anyway, I want to be able to load the file in the browser as straight html such that it only gets interpreted by the browser.....it is Internet expl version 7
IT Manager
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
netmunky - http:#20016152.  I'm glad it worked for you.

bol
b0lsc0ttIT Manager
CERTIFIED EXPERT

Commented:
I'm glad I could help.  Thanks for the grade, the points and the fun question.

bol

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.