nadeemshafi9 Posted October 5, 2007 Share Posted October 5, 2007 i have a function with a url, the function is included in every page, the url becomes wrong if i include it in a higher directory so i need to know how to state the server root directory with javascript, thanks guys Quote Link to comment Share on other sites More sharing options...
nadeemshafi9 Posted October 5, 2007 Author Share Posted October 5, 2007 do i have to use phpi kniow i can do it with ajax or get the directory from php by naming the .js file to .php and interlkacing it, but this is too much right now the site is well developed Quote Link to comment Share on other sites More sharing options...
mainewoods Posted October 7, 2007 Share Posted October 7, 2007 if you can get it from php, then do this: <script type="text/javascript"> var myjsdir = "<?php echo $dirfromphp; ?>"; </script> <script type="text/javascript" src="yourfile.js"></script> --php transfers it's variable value to a javascript variable using the inline javascript --the javascript variable 'myjsdir' can now be referenced inside the scripts in 'yourfile.js' --it's what I do because then I can leave the external javascript files with the .js extension for easier control of caching of them. Quote Link to comment Share on other sites More sharing options...
fenway Posted October 7, 2007 Share Posted October 7, 2007 i have a function with a url, the function is included in every page, the url becomes wrong if i include it in a higher directory so i need to know how to state the server root directory with javascript, thanks guys You'll never be able to see anything "above" the www directory. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.