šljaker šljaker - 6 months ago 91
jQuery Question

URL helper in JavaScript

I'm using jQuery Lightbox for my image gallery.

The URL for the button image is '


That works fine if my URL is '

If I use another route like '
' then URL to button images is incorrect.

Can I use
inside .js files?

This is how I call .js files:

<script type="text/javascript" src="<%= Url.Content("~/Scripts/jquery.lightbox-0.5.js") %>"></script>


You can't use Url.Action() inside .js files. But you can define global variable and use it in you js file.

<script type="text/javascript">

    var imageUrl = "<%= ... %>";