banner2.add("FLASH", "../Banners/1.swf", 10, 60, 468,"h...">

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");
+5
source share
3 answers

I got a solution. We do not need to do ny formatting in javascript. I used escape sequences to write the path. thanks nyway

banner2.add("FLASH", "<%= ResolveUrl("~/Banners/1.swf") %>", 10, 60, 468,"techpint.com","_blank";); 
+8
source

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.

:

+2

I think so while your page is being processed by ASP.NET, for example. it is not only a static HTML file.

0
source

All Articles