My solution to this is to put, in the layout file, before all other js includes, this line: <script type="text/javascript"> var wr = '<?=$this->webroot?>';</ script> now the variable wr is available in all your js scripts.
On Oct 4, 3:13 pm, Joel Stein <[EMAIL PROTECTED]> wrote: > I have started to get in the habit of keeping all my links relative to > the webroot, by taking advantage of $html->link(). It's a wonderful > feature, because it allows me to put my website under any directory > and everything just works. > > However, one difficulty I encountered was accessing the webroot from > javascript files. For instance, if a javascript file has to access a > CSS or SWF file, I want a bulletproof way to access it. I used to > just do something like this: > > var $someFile = "/css/some_file.css"; > > But that won't work if I put my application under a directory. I've > tried a combination of "../css/some_file.css" but that doesn't work > either. > > I know this is a javascript question, but has anybody encountered this > before and come up with a solution? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---