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 best solutions below

1
On

Drupal 7

Drupal.settings.basePath

Drupal 8

drupalSettings.path.baseUrl
1
On

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