I am trying to get Magento BaseUrl through javascript in the head.phtml file and then use it in the jquery.hello-lightbox.min file, where I need baseUrl to get some images.
Here is what I have in the head.phtml file:
<?php $baseUrl = $this->getBaseUrl() ; ?> <script type="text/javascript"> var baseUrl = <?php echo $baseUrl ; ?> function getBaseUrl(baseUrl) </script>
Then in /js/jquery.hello-lightbox.min I have:
(function($){ function getBaseUrl(baseurl) { var domain = baseurl } var urrl = 'http://'+domain+'/skin/frontend/default/customtheme/images/lightbox/'; $.fn.lightBox=function(settings)settings=jQuery.extend({overlayBgColor:'#000',overlayOpacity:0.8,fixedNavigation:false,imageLoading: urrl+'lightbox-ico-loading.gif',imageBtnPrev:urrl+'lightbox-btn-prev.gif', . . . . . . . . . .
But that does not work. It actually seems like I can't even pass the php $ baseUrl variable to var baseUrl in head.phtml
Do you have any ideas?
javascript base-url magento
Guille
source share