Reputation: 1521
I downloaded the dojo toolkit and open the dijit/themes/themeTester.html. The dojo can't work. I have to copy the toolkit to the webapp directory of my web server. Then I access the same html through HTTP. The dojo works.
During the development, do I have to always deploy a page to web server for testing?
Thanks.
Upvotes: 0
Views: 245
Reputation: 43956
This behavior is not Dojo-specific. Some browsers (Firefox comes to mind) prohibit web pages loaded directly from file system to load resources outside of their home directory for security reasons.
Example: your web page is in /home/bob/page.html
. It can include following resources:
bob.js
(effective path: /home/bob/bob.js
)./sam.js
(/home/bob/sam.js
)abc/spot.js
(/home/bob/abc/spot.js
)It cannot load following resources (even if they exist):
../bob.js
(/home/bob.js
)/home/tom/script.js
../tom/script.js
(/home/tom/script.js
)Theoretically you can go into Firefox guts and turn this "feature" off, but you may encounter other problems:
Other than that you should be able to run any web application directly from file system. Just make sure that the whole app is inside one folder, all HTML pages are in the top folder (or in subfolders, but do not use anything "above" them), avoid absolute paths, and "go up" symbols (..
) in paths that take you outside of the main folder (even temporarily), and always test your XHR responses.
Upvotes: 2