Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window.location for a local file

Status
Not open for further replies.

NJDrew

Technical User
Dec 21, 2001
31
US
Ok, I wanted to use a window.locaton to open a html file on my hard drive. I have setup a simple way to try and do this, but I am getting the error:

"Can not find 'file:///C:happy.html'. Make sure the path or internet address is correct."

The file name and path are correct. What am I doing wrong?

<html>
<head>
<script language = &quot;JavaScript&quot;>
function changeLocation(){
this.window.location = &quot;C:happy.html&quot;;
}
</script>
<body>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;change&quot; onclick=&quot;changeLocation();&quot;>
</body>
</html>

&quot;Mistakes are the portals of discovery&quot;
James Joyce
 
did you try :

<html>
<head>
<script language = &quot;JavaScript&quot;>
function changeLocation(){
this.window.location = &quot;C:\happy.html&quot;;
}
</script>
<body>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;change&quot; onclick=&quot;changeLocation();&quot;>
</body>
</html> Gary Haran
 
did you try :

<html>
<head>
<script language = &quot;JavaScript&quot;>
function changeLocation(){
location.href = &quot;C:\happy.html&quot;;
}
</script>
<body>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;change&quot; onclick=&quot;changeLocation();&quot;>
</body>
</html> Gary Haran
 
Gary, I tried both of your suggestions and neither want to work. Thank you for the help though. &quot;Mistakes are the portals of discovery&quot;
James Joyce
 
Ok use this

<html>
<head>
<script language = &quot;JavaScript&quot;>
function changeLocation(){
window.location = 'file://C:/happy.html';
}
</script>
</head>
<body>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;change&quot; onclick=&quot;changeLocation();&quot;>
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top