SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

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

    Unhappy Dynamically adding event handlers to events using javascript

    <html>
    <head>
    <script type="text/javascript">
    function changeSize(strTemp)
    {alert(strTemp);}
    </script>
    </head>
    <body>
    <script type='text/javascript'>
    document.body.onload = function(){changeSize('added');};
    </script>
    </body>
    </html>

    This addition of eventHandler dynamically works in IE but not in mozilla.
    How to do it for mozilla
    In the above code 'added' is displayed in alert box on page load in IE, how to make it happen in mozilla.

  2. #2
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in your second script, use window.onload= or just onload= instead of document.body.onload=.

  3. #3
    SitePoint Member
    Join Date
    Nov 2007
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Thanks

    Thanks, Your reply solved my problem.


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
  •