最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Firefox and Local Files - Stack Overflow

programmeradmin3浏览0评论

Is there way to access local files not in the current directory on Firefox?

I've done this

about:config -> security.fileuri.strict_origin_policy to false

from a ment in jQuery's .getJSON using local files stopped working on Firefox 3.6.13.

It's especially noticeable when I use jQuery.getScript() and call a file from a subdirectory or the parent directory.It says it's loaded but doesn't do anything with it, it appears.

Is there way to access local files not in the current directory on Firefox?

I've done this

about:config -> security.fileuri.strict_origin_policy to false

from a ment in jQuery's .getJSON using local files stopped working on Firefox 3.6.13.

It's especially noticeable when I use jQuery.getScript() and call a file from a subdirectory or the parent directory.It says it's loaded but doesn't do anything with it, it appears.

Share Improve this question edited May 23, 2017 at 10:33 CommunityBot 11 silver badge asked Sep 1, 2011 at 18:08 NebulaFoxNebulaFox 8,3239 gold badges51 silver badges67 bronze badges 2
  • Do you really need to do this? If you're developing a web application, why not install a web server? – lonesomeday Commented Sep 1, 2011 at 18:10
  • 1 It's for testing, so yes I need this. And since I'm a programmer I'm lazy :P But I'll take what you say into consideration. – NebulaFox Commented Sep 1, 2011 at 18:13
Add a ment  | 

1 Answer 1

Reset to default 4

Is there way to access local files not in the current directory on Firefox?

Yes, you set security.fileuri.strict_origin_policy to false. If you've done it already then your problem is caused by something else and you need to ask a different question (preferably with some code). I tested it with the following HTML file:

<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript">
  jQuery.getScript("file:///.../test.js", function(data, status){
    alert(status + ":\n\n" + data + "\n\n" + window.a);
  });
</script>

With test.js being:

alert("Test succeeded");
var a = 1;

With security.fileuri.strict_origin_policy set to true nothing happens (not even a message in the Error Console). Once it is set to false I see the message "Test succeeded" and then another message saying success: alert("Test succeeded");. As one would expect.

That's Firefox 6.0.1 on Windows 7 x64. Edit: It's the same with Firefox 3.6.21.

发布评论

评论列表(0)

  1. 暂无评论