SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can I execute a JavaScript function on page load not after??

    Hello everyone, allow me to start off by saying you guys have a well disputed rep around the admin forums. This site comes very highly recommended and I see you guys have the content to back it up; super glad I joined. So now to the java stuff...

    I have been trying to work my way around this issue for some time now. I am trying to stop a marquee from scrolling as soon as the page start to load not after. I have been using this to pause the marquee with JavaScript but the command does not execute but after the page loads; after all the html loads.

    This is the JavaScript:

    Code:
    <script language="JavaScript">
      window.onload=function(){
            myMarquee.stop();
        }
       function function1(){
            document.all.myMarquee.direction = "left";
        }
        function function2(){
            document.all.myMarquee.direction = "right";    
        }
        function function3(){
            document.all.myMarquee.stop();
        }
          function function4(){
            document.all.myMarquee.start();             
        }
    </script>
    This is what I insert in my template:


    Code:
    <marquee id="myMarquee" BEHAVIOR=ALTERNATE>&nbsp;{vb:raw film_seriti}a></marquee>
    <img src="http://aniworlds.net/members/equinox/albums/random-renders/1874-left.png" onclick="function1();">
    <img src="http://aniworlds.net/members/equinox/albums/random-renders/1877-stop.png" onclick="function3();">
    <img src="http://aniworlds.net/members/equinox/albums/random-renders/1876-start.png" onclick="function4();">
    <img src="http://aniworlds.net/members/equinox/albums/random-renders/1875-right.png" onclick="function2();">
    With this code the marquee does stop but after the page loads completely so as the page loads the marquee start to scroll and then stops as soon as the page finishes loading but with the first image of the marquee have way out. I need to be able to load the marquee 100% stopped as the page loads so then I can use the buttons I placed to control the marquee.

    My question is:

    Is there ANY way to completely stop the marquee from scrolling as soon as the page loads???

    Any information anyone could share would be very much appreciated. Thank you for your time.

    p.s: Also if anyone has any idea on how to scroll the marquee by click; meaning by every click of the mouse the marquee moves either left or right, would be even better.
    p.s: Noted that this code does NOT work in FF for some reason. The stop does not work and the buttons don't respond. Any ideas why in FF they don't work but in GC and IE they do??

    Best Regards,

    Gustavo P.
    <snip/>
    Last edited by Mittineague; Jun 23, 2011 at 16:59. Reason: Please wait until you get your signature for your links.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •