You can. I am not sure if you need
var myImg = '{{=IMG(_src = URL('static','image/myImage.jpg') )}}'; //
single quotes contain '<img ..../>'
or
var myImg = "{{=URL('static','image/myImage.jpg')}}"; // url only
On Saturday, 25 August 2012 14:56:05 UTC-5, shartha wrote:
>
> Hi,
>
> Is there any way to set the value of a global javascript variable defined
> in a .js file using web2py helpers?
> I have an image in my static/image folder and I want to use the URL of the
> image in the javascript function.
>
> something like this:
>
>
> // In the mySite.js file
> var myImg = "{{IMG(_src = URL('static','image/myImage.jpg') )}}";
>
> function myFunction(){
> // use myImg variable here
> // the src attribute of myImg should be set to
> "localhost/mySite/static/image/myImage.jpg"
> };
>
>
> Thanks!
>
>
>
--