views:

124

answers:

3

I noticed that when I open HTML file locally by double clicking on it, it will not "run" the same as if I had it on a web server and opened it by HTTP GET request.

I need to have a local HTML file a user can open by double clicking on it. This HTML file has several JQuery load calls such as this:

$("#content").load("http://somepage.com/index.html");

I want to update several divs with content from remote sites.

This works fine If I have this file on a web server but not if I double click it under windows explorer... How can I "make" the file "run" as it would on a web server?

+3  A: 

I think you pretty much cannot. This has to do with domain-access restrictions, which are there to avoid cross site scripting and the likes.

The files on your hard drive are especially limited - think what the life could be if they were allowed to treat your whole hard-drive as a single domain.

EFraim
A: 

If you want things to work properly you need to be running a server. XAMPP is a pretty good bet as it's easy to install and set up.

Any non-AJAX javascript will work fine as is though, as long as the paths to include any css or js are relative.

Rich Bradshaw
So he's going to give this out to whoever, and they're going to use it and it's only going to work if he has his computer on? Horrible solution. Most ISPs don't allow this in their Terms, either. Some even go as far as to block port 80.
Sneakyness
@Sneakyness: What your comment has to do with either the question OR the answer?
EFraim
A: 

You can't do this locally. You have to have it hosted somewhere for this to work. It's done this way for the sake of security.

What are you trying to do that you "need" to have this?

Sneakyness