Can i use resolurl in javascript
<script language="javascript" type="text/javascript">
banner2.add("FLASH", "../Banners/1.swf", 10, 60, 468,"http://www.techpint.com","_blank");
banner2.add("FLASH", "../Banners/2.swf", 10, 60, 468,"http://www.tapasya.co.in","_blank");
</script>
Now I want to get the base url of the site so that I can specify the path to my Flash file on all pages. this script is part of my main page. can I run "<% = ResolveUrl (" ~ / Banners / 1.swf ")%>" in javascript.
banner2.add("FLASH"," <%= ResolveUrl("~/Banners/1.swf") %> ", 10, 60, 468,"http://www.techpint.com","_blank");
It is very simple, but it is often asked.
Here's how you do it:
On the main page of the site, enter the following:
<script type="text/javascript">
var baseUrl = "<%= ResolveUrl("~/") %>";
</script>
Then in your javascript file put this function:
function ResolveUrl(url) {
if (url.indexOf("~/") == 0) {
url = baseUrl + url.substring(2);
}
return url;
}
, intelli-sense .
ResolveUrl ~/right javascript.
, !
, -, " url", Page.Theme.