2

I would like to add a js file thats outside my drupal installation dir, but keep it relative to that dir.

mysite
  |-- drupal
  |-- dirWithJsFile
      |-- thisfile.js

i have already tried things like

/../dirWithJsFile/thisfile.js
../dirWithJsFile/thisfile.js

but add_js seems not be able to go outside the drupal dir or is there an option i must set?

0

2 Answers 2

0

The javascript file you want to add is not inside your drupal installation so you need to add it the same way you would do it with an external file:

drupal_add_js('http://yourdomain.com/dirWithJsFile/thisfile.js', 'external');

See drupal_add_js for more informations.

0

In D6, no dice, but in D7, you could fudge it with setting $options to external and then using the full sitename and path to the file.

2
  • I use D7, but the site url directs to the drupal directory
    – dazz
    Commented Dec 12, 2011 at 14:48
  • 1
    well, everything is relative to the webroot, so your file would need to be under there anyway for security reasons. otherwise, someone could do www.mysite.com/etc/passwd (as an example to date myself)
    – Jimajamma
    Commented Dec 12, 2011 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.