base_url in js file

10k views Asked by At

how we can print base_url in js file (in drupal)?please

2

There are 2 answers

1
yoavmatchulsky On

Drupal 7

Drupal.settings.basePath

Drupal 8

drupalSettings.path.baseUrl
1
Matt V. On

You can use $base_path. See en example on The Drupal JavaScript API under the "Drupal.settings" section.