[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

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

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);
0
smmsmm57
Asked:
smmsmm57
  • 6
  • 3
2 Solutions
 
b0lsc0ttCommented:
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
0
 
smmsmm57Author 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?
0
 
smmsmm57Author Commented:
are you saying that the syntax looks correct?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
b0lsc0ttCommented:
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
0
 
b0lsc0ttCommented:
Another way to write it which you can try is ...

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

bol
0
 
smmsmm57Author 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
0
 
b0lsc0ttCommented:
Thanks for the details.  I think I understood it correctly but let me know if I get something wrong. :)

The page with the script above, does it use an "http://localhost" URL as the address or "file:///c:"?  How is the script above (loadmain) run is basically what I am trying to find out?

It seems like you could do what you want by putting a shortcut to the file in your Startup folder.  Since that will basically use the file path it should not need or require localhost or IIS.  Let me know if you need info on making that shortcut.

Let me know how this helps or if you have a question.

bol
0
 
netmunkyCommented:
javascript in IE will interpret:
file:///c:\temp\test2.html
as:
file:///c:empest2.html

this works just fine for me (after clicking the popup to allow the javascript to run in the local zone)
<script>
function loadmain()
{
  window.location.href='file:///c:/temp/test2.html'
}
setTimeout("loadmain()",1000);
</script>
0
 
b0lsc0ttCommented:
netmunky - http:#20016152.  I'm glad it worked for you.

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

bol
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 6
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now