Jump to content

Issue with slide show example


androidiscool

Recommended Posts

I coded it and it all works except for unload. It only displays the 3 dots and no pictures. If you click on a dot then it all works. I use a master page and code behind in asp.net c#. Anyone know how to call the function in code behind default.aspx.cs to display a pic when web site is opened? You can see site which is under construction http://www.sueandpatphoto.com

Link to comment
Share on other sites

A page loads from top to bottom, your slideshow JavaScript is run before the html and references to slideshow classes have been rendered or exist, so its attempt to show first image with

var slideIndex = 1; 
showSlides(slideIndex);
Will fail because of this. When you click a dot, because everything is fully rendered, then it functions correctly. That is why you will find that this code is placed AFTER the slideshow.
Link to comment
Share on other sites

A page loads from top to bottom, your slideshow JavaScript is run before the html and references to slideshow classes have been rendered or exist, so its attempt to show first image with

var slideIndex = 1;
showSlides(slideIndex); 

Will fail because of this. When you click a dot, because everything is fully rendered, then it functions correctly. That is why you will find that this code is placed AFTER the slideshow.

 

Pretty obvious in it? place link or JavaScript code related to slideshow below html code related to slideshow or place your js code within

window.onload=function(){

///slideshow code here

}

You should now days, place links or inline JavaScript code just before </bod> tag, this helps load page faster by loading html and css first, then JavaScript coding.

Edited by dsonesuk
Link to comment
Share on other sites

OK now it works. thanks for your help. However I had to add the link to the master page before the </body> as you said. But when I tried to remove it from default.aspx I just got a blank page. So it has to be in both places. Dont understand why but glad it works. thanks again.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...