I'm building a web page which I can only access by ftp:

ftp://192.168.0.1.cutthis/mypage.html

This url opens the page in the browser as I would have used http protocol.

The page contains a dynamic GUI. To make its development easier, I have moved all the javascript to a machine (192.168.0.2) I have access to, so I can edit it more quickqly. In the html source code of mypage.html, the script line is:

<script type="text/javascript" src="file://///192.168.0.2/myscript.js"></script>

FF and Chrome load the script (Firebug confirms this) but don't run it. Only IE run it.

How can I force FF and/or Chrome to run the script? Or how can I solve the problem overwise?

有帮助吗?

解决方案

cross-protocol scripting?

Method 1:

For Chrome try extension: LocalLinks

For FF try extensions: LocalLink, Local Filesystem Links, IE Tab

Method 2:

run Chrome with --allow-file-access-from-files flag or may be try other flag which disables cross-site scripting (waring: this is dangerous)

configure Security Policy in FF (create special policy for your site - read here: Links_to_local_pages_don't_work, Security_Policies)

But, I'm still not sure if all of this helps. FTP: URL is a special case

其他提示

MDN says of the same origin policy:

The same origin policy prevents a document or script loaded from one origin from getting or setting properties of a document from another origin.

myscript.js is from the origin file:////192.168.0.2/ but it is being loaded into a page with the origin ftp://192.168.0.1.cutthis. My guess is that the cross-domain script cannot perform the manipulation you expect it to do because it is loaded from a different origin.

The solution would be to host both the script and the page on the same origin (i.e., also serve the HTML page over file://, or even better, serve them both on a local HTTP server).

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top