SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast stilltsie's Avatar
    Join Date
    Sep 2006
    Location
    Orlando, FL
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    window.onload problem!

    Hey guys, Im pretty new at javascript but know enough to get myself into trouble. Im trying to run two scripts, curvycorners and thickbox to be precise, and only one will load. Now as far as I can tell this is because only one can take adavantage of window.onload and not both, so naturally curvy corners loads but thickbox wont. I'm sure there is a workaround out there for this, but I just have no idea what to do or where to start.

    If you guys can, please take a look at www.brettadams.net/new/whatidid.html

    Thanks alot!!!

  2. #2
    SitePoint Zealot bobber205's Avatar
    Join Date
    Sep 2006
    Location
    Oregon
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This may totally be out of the ballpark, but it might work to assign the onload event to a function that calls two functions, one for curvy and one for thick.

  3. #3
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Either:

    a) Use an anonymous function for the window.onload:
    Code:
    window.onload = function () {
      curvyCorners();
      doThickbox();
    }
    b) Use a better event registration function that can cope with multiple functions attached to the same event.

    c) Don't use window.onload.

  4. #4
    SitePoint Enthusiast stilltsie's Avatar
    Join Date
    Sep 2006
    Location
    Orlando, FL
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks buddy, Ive read that article many times before posting, but I really dont know javascript well enough to implament it. Ill work on it, but I dont know if I can get it to work.

  5. #5
    SitePoint Enthusiast stilltsie's Avatar
    Join Date
    Sep 2006
    Location
    Orlando, FL
    Posts
    96
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    So I tried your first suggestion but ran into a problem Again, I dont know much but I think the problem lies in the fact that another script belonging to curvycorners is anonymous as well.

    Code:
    <script type="text/JavaScript">
    
      window.onload = function()
      {
             settings = {
              tl: { radius: 20 },
              tr: { radius: 20 },
              bl: { radius: 20 },
              br: { radius: 20 },
              antiAlias: true,
              autoPad: true,
              validTags: ["div"]
          }
    
    
          var myBoxObject = new curvyCorners(settings, "myBox");
          myBoxObject.applyCornersToAll();
      }
      
    </script>
    So I added this above it, like you said but now its only calling thickbox and not curvycorners.
    Code:
    <script type="text/javascript">
    window.onload = function () {
      curvyCorners();
      doThickbox();
    }
    </script>
    I also attempted to replace dothickbox() with TB_init()


    Thanks for your help!

  6. #6
    Caveat surfer Buddy Bradley's Avatar
    Join Date
    May 2003
    Location
    Cambridge, UK
    Posts
    2,366
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just copy the curvyCorners window.onload stuff into your main window.onload function, so you have something like this:
    Code:
    <script type="text/JavaScript">
    
      window.onload = function()
      {
             // Curvy corners init stuff
             settings = {
              tl: { radius: 20 },
              tr: { radius: 20 },
              bl: { radius: 20 },
              br: { radius: 20 },
              antiAlias: true,
              autoPad: true,
              validTags: ["div"]
          }
    
    
          var myBoxObject = new curvyCorners(settings, "myBox");
          myBoxObject.applyCornersToAll();
    
             // Thickbox init stuff
             TB_init();
      }
      
    </script>
    An alternative is a more flexible addEvent, like this one.


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
  •