I develop a web app using the dojo framework. This app must be loaded by a browser using the file:/// protocol (It will become a Cordova/Phonegap application for Android/iPad). The index.html file looks like:
Head section:
<script type="text/javascript">
var dojoConfig = {
parseOnLoad: true
}
</script>
<script type="text/javascript" src=""dojo.js"/>
<script type="text/javascript">
dojo.require("dojox.mobile.parser");
dojo.require("dojox.mobile");
</script>
Body section:
<script type="text/javascript">
dojo.require("dojox.mobile.parser");
dojo.require("dojox.mobile");
</script>
It was taken from IBM lesson (Mobile application development, Part 1: PhoneGap and Dojo Mobile on Android)
So there are two problems:
1) dojo tries to load modules but failed to do it using the file:/// protocol. The HTTP protocol is requiered.
2) In the index.html I use a custom build of dojo made by the web builder. This build consists of a single file which contains modules I need. However these modules must be required which makes the framework try to load them from unexisting files though they has been already loaded in the big custom dojo.js
May be someone knows how to solve these two problems.
Which browser are you testing your code on? Chrome does not allow multiple domains within a single Html file, due to security concerns. Try your code on the firefox browser it should prompt a warning and run the code. Also make sure the index.html file are in the parent directory of the dojo source (dojo library). i.e
your directory structure should be as shown below
|--[dojo_source/dojo_library]
|
|-index.html.
also run your code with the file protocol in the browser file://
Hope this helps.
Another alternative is to install a web server. You can try the "mongoose" web server which is very light just 136KB in size. Which you can then setup to run your dojo code. I have been using the web server and it has been great for unit testing my code.