Is it possible to use client side .js file to load a local .htmlfile?

Y

ybi10

Hi,

I have a .js file, we want to make it to load a html file right next
to it, both files are on client system. I couldn't find any such
examples and some posts talked about JavaScript security issues, I
wonder if it is related to what I want.

Please suggest, and even better, provide sample or pseudo code.

Some one said .js file is not really JaveScript file, though Microsoft
named it 'JavaScript'.


Thanks,
Peter
 
J

JR

Hi Peter,
You cannot open, read and/or write local files solely with JavaScript
and a browser (client-side). Some years ago, I used IE (5 or 6 ?) and
window's FileSystemObject (which is located in Scrrun.dll file), but
this was a very restricted solution and therefore not applicable to
the world wide web. Nowadays it seems to be very hard to do that with
IE7 under Windows Vista, because of security restrictions. Firstly,
we'd need to turn off IE7 Protected Mode and change some of it's
security settings which is a bad idea.

For instance:

function test() {
var fso, f1;
fso = new ActiveXObject("Scripting.FileSystemObject");
f1 = fso.GetFile("c:\\temp\somefile.txt");
window.alert("File last modified: " + f1.DateLastModified);
}

However, you can use a server-side script such as PHP / Asp to read /
write files in a web server.

Cheers,
Joao Rodrigues
 
J

Jorge

Hi Peter,
You cannot open, read and/or write local files solely with JavaScript
and a browser (client-side). (...)

Hi Joao,

Both files are local... (!) : both come from the same "domain" (via
the file: protocol)... (IOW, ISTM that yes, it can be done).
 
J

JR

Hello, Jorge.
How is the beautiful Madrid?
I had not thought of that possibility (file protocol).

Saludos desde Brasil,
João Rodrigues
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top