SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2008
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Defining which JS runs first

    Code:
    <body onload="javascript:gow()">
    
    <script type="text/javascript" src="http://example.com/s.js"></script>
    
    <script>
    function gow() {
    
    }
    </script>
    
    </body>
    I need the gow() function to wait until the first script is run. Any suggestions?

  2. #2
    Guru in training bronze trophy SoulScratch's Avatar
    Join Date
    Apr 2006
    Location
    Maryland
    Posts
    1,838
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps this could work..

    Code:
    <script type="text/javascript" src="http://example.com/s.js"></script>
    <script type="text/javascript">
    function gow() { }
    gow();</script>
    </body>
    So the external function runs first, right after everything else in the body and then gow.

    If you have access to the external code, you could possibly just call gow() from there. It really does depend on what's in the external script... would help if you posted it.


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
  •