views:

45

answers:

2

So I need to load a file from disk somehow, and access its contents.. Sort of like how

<link rel="stylesheet">

works. Is there a way to do this? XHR requires a web server.. and using something like the above doesn't let me access the contents of the file..

+1  A: 

Assuming that your page is also on the local disk, you should be able to use XHR with a file:// URL.

SLaks
oh interesting, I didn't know that. So I guess I should check the url of the current file, to see if it's being loaded from disk.
cloudhead
works great, thanks.
cloudhead
+1  A: 

Do you mean loading from a CD or the HDD? You'll need the full address that it is stored at, for example, something on the desktop would be:

"file:///c:/documents%20and%20settings/user/desktop/file.css"

%20 means a space.

Tim