SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    2 functions in a body tag

    How would I call two functions in a body tag? Currently I have...
    Code:
    <body onload="init(); checkCookie();">
    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just remove the last semicolon, and it should be fine

    Or else you could create a fuction to do it ..

  3. #3
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script type="text/javascript">

    function init()
    {
    alert('called from init');
    }
    function checkcookie()
    {
    alert('called from check cookie');
    }
    </script>

    <body onload="init(); checkcookie();">

    hehe, u learning javascript now then sketch:P, if this has a mistake i can't help it im on a damn mac

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sketch you get an error because its trying to call a javascript function and you havent defined a function. It has nothing to do with the last semi colon. Unless there is another function ollowed after

  5. #5
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was presuming there was a function after it ...

  6. #6
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have defined a function.
    Code:
    function checkCookie() {
     var temp = getCookie("popup");
     if(!temp==1) {
      setCookie("popup",1);
      window.open('cd.php','pop1','directories=no, scrollbars=no,width=350,height=125,left=225,top=150')
       }
    }
    Check out www.elimfellowship.org/usmd to see the source.

    The problem is is that init() is called on every page and I only want the checkCookie() on this page so I can't combine the two.

    Sketch
    Aaron Brazell
    Technosailor




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
  •