Setting the Image Path
For your javascript to be able to load images it needs to know the correct path from the web root, this variable is available as a JavaScript global. To see default js globals just view source of any page generated by Seagull:
<script type="text/javascript"> <!--
var SGL_JS_WEBROOT="http://localhost/seagull/branches/0.6-bugfix/www";
var SGL_JS_WINHEIGHT=500;
var SGL_JS_WINWIDTH=600;
var SGL_JS_SESSID="";
var SGL_JS_CURRURL="/seagull/branches/0.6-bugfix/www/index.php/mymodule/mymanager/action/view/";
var SGL_JS_THEME="my_theme";
var SGL_JS_DATETEMPLATE="%d %B %Y, %H:%M";
//--> </script>
In this example we are interested in both SGL_JS_WEBROOT and SGL_JS_THEME.
To set the correct path in your custom javascript files, just use these two javascript globals as follows (example taken from lightbox.js):
/* * Configuration */ var fileLoadingImage = SGL_JS_WEBROOT + "/themes/" +SGL_JS_THEME +"/images/loading.gif"; var fileBottomNavCloseImage = SGL_JS_WEBROOT + "/themes/" +SGL_JS_THEME +"/images/closelabel.gif";
If you have some specific module images located in <moduleName>/www/images simply call
var imagePath = SGL_JS_WEBROOT + "/moduleName/images/image.gif";
See Also
- Howto/JavaScript Javascript Tips
- Howto/JavaScript/ImagePaths Setting the Image Path
- Howto/JavaScript/IncludeFiles Adding !JavaScript Files
- Howto/JavaScript/OnloadEvents Managing onload and onreadyDOM events
- Howto/JavaScriptAndCssImprovements CSS and Javascript reorganization and optimization
