简体   繁体   中英

relative path to images in external js script

I'm writing a component in Joomla and want to use JavaScript.

I got the JavaScript part working in a separat test html page, but now I want to include it in the Joomla component.

The problem is the relative file paths for the images. The images are stored in the media folder of joomla:

media/com_component/images

I include the external js-file with this command:

$document->addScript(JURI::Root().'components/com_component/script.js');

In the script I need the path to the image folder. I don't want to hard code the absolute path in the script. How can I get the relative paths? Do/can I use Joomla functions for that?

Thank you

I chose to put the file path information in the css file (set the image as the background of the link). This way the js-script is independent of the image's file path.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM