I made a body script to replace an image by pressing on buttons. This is place in an article in the CMS Joomla.
My working script is:
<script type="text/javascript">
function purplewingfoil() {
document.getElementById("wingfoilcolor").src = "http://localhost/Joomlagraf/Astroid-JoomDev/images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-purple.png";
}
function yellowwingfoil() {
document.getElementById("wingfoilcolor").src = "http://localhost/Joomlagraf/Astroid-JoomDev/images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-yellow.png";
}
I really like to have that url being relative to the Joomla site folder, something like:
.src = "/images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-yellow.png";
I’m an absolute zero in Javascript, I just code by deduction....
Thanks in advance for your help!
====================================================
Thanks, yes, I try directly the relative path —> /images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-purple.png
But I end-up with the wrong path — > http://localhost/images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-purple.png
The real path on my Mamp Pro local server is —> http://localhost/Joomlagraf/Astroid-JoomDev/images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-purple.png
This is because I have many sites at my localhost location and the added Joomlagraf/Astroid-JoomDev correspond the folders path where that particular site is situated. This mean that it will work in live condition when the site is properly redirected.
It will be great to find a way to make it work with the relative path —> /images/menu/produits/wing-foil/wing-foil-colours-choice/wing-ride-colours-purple.png in both local and live environmemt... Not sure How?