[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

server path in a javascript

Posted on 2011-10-10
8
Medium Priority
?
265 Views
Last Modified: 2012-05-12
i have a slide show on my banner in my master page and have problem when i have content page when it is in a folder or sub folder.

if my src image/pic.jpg

my javascript works fine in the main folder but if i have a sub folder the image src do not work.


my java function

        function ReceiveServerData(rValue)
        {
            //Receive server's response of a string rValue, which is prepared in the server's function
            //GetCallbackResult()
            var wds = rValue.split(";");
            //Assign the transition effect
            document.getElementById("ctl00_photo").style.filter = wds[1];
            //Preload the image file from server.  When finishing download, imageLoaded function will be called
            //with the img object as the argument                          
            var img  = new Image();
            img.onload = function(){ imageLoaded(this); }
            img.onerror = function(){ imageError(this); }
            img.onabort = function(){ imageError(this); }
            img.src = wds[0];                                            
        }

        function imageLoaded(img)
        {
            var imgID = '<%= photo.ClientID %>';
            var photo = document.getElementById(imgID); //Find the image control object  
            photo.filters[0].apply();                       //Apply the transition effect
            photo.filters[0].play();                        //Play the effect and display the new image
            photo.src = img.src;                            //Assign the image to the image control
           
            window.setTimeout("getNextImage()", c_interval);//Initiate the next request
        }
0
Comment
Question by:JCWEBHOST
  • 5
  • 3
8 Comments
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36947000
When it is folder then you need image source path should be ../image/pic.jpg. If sub-folder then path should be ../../image/pic.jpg
0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36947006
You can modify js function like below (for folder)


function imageLoaded(img)
        {
            var imgID = '<%= photo.ClientID %>'; 
            var photo = document.getElementById(imgID); //Find the image control object  
            photo.filters[0].apply();                       //Apply the transition effect
            photo.filters[0].play();                        //Play the effect and display the new image
            var path = '../' + img.src;
            photo.src = path;                            //Assign the image to the image control
            
            window.setTimeout("getNextImage()", c_interval);//Initiate the next request
        }

Open in new window

0
 

Author Comment

by:JCWEBHOST
ID: 36947011
yes but i have my java code in my master page, how do i change the src?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:JCWEBHOST
ID: 36947016
my java code is in the master page a i do not know how to change the src?
0
 
LVL 17

Accepted Solution

by:
sonawanekiran earned 1000 total points
ID: 36947021
It will not matter placing javascript code either in master page or aspx page. Have you tried above solution?
0
 

Author Comment

by:JCWEBHOST
ID: 36947035
yes the image do not show
0
 

Author Comment

by:JCWEBHOST
ID: 36947106
i used this

http://www.ramcon.jcwebhostza.com/+ img scr


and it works
0
 

Author Closing Comment

by:JCWEBHOST
ID: 36947115
Thanks
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses
Course of the Month18 days, 4 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question