0

I have a JavaScript function like this:

<script type="text/javascript" src="http://tem.parstools.com/zeos/js/animatedcollapse.js"></script>

<script type="text/javascript">
animatedcollapse.addDiv('bannertop', 'fade=0,speed=200,persist=1')

animatedcollapse.ontoggle=function($, divobj, state){
if (divobj.id=="bannertop") //only react to these two collapsible DIVs
document.getElementById(divobj.id+"-toggle").src=(state=="block")? "image1.png" : "image2.png"
}

animatedcollapse.init()
</script>

This function is called when user click on the specific image like:

<a href="javascript:animatedcollapse.toggle('bannertop')"><img id="bannertop-toggle" src="image_source" /></a>

But, I want first time my site loading this function calling automatically.

sorry for my weak English typing.
Can any body can help me?
thanks

Adam D. Ruppe
  • 25,382
  • 4
  • 41
  • 60
sadegh
  • 1
  • 1
  • 4
  • I think this will help http://stackoverflow.com/questions/3698200/window-onload-vs-document-ready – superdb Nov 20 '14 at 01:01

1 Answers1

0

You can simply call the method in the script

animatedcollapse.toggle('bannertop')

inside the <script> tag. You might want to put this code at the bottom of the html file, right before the </body> tag.

Adam D. Ruppe
  • 25,382
  • 4
  • 41
  • 60
  • thanks its working but with this code first time my function called but when i click on my image no event calling now what is my wrong? – sadegh Nov 20 '14 at 01:07