Need a JS programmer to execute some JS when one of my pages loads - paid

Discussion in 'JavaScript' started by fadetoblack22, May 7, 2009.

  1. #1
    I have a page on my site with some JS that performs an action when the user clicks a button. I need some help to get the action to occur on page load.

    I will pay you via paypal after the job is done. Let me know and I will pm you with the page that needs the work.

    I think it is done using code similar to this:

    function addLoadEvent(func) {
      var oldonload = window.onload;
      if (typeof window.onload != 'function') {
        window.onload = func;
      } else {
        window.onload = function() {
          if (oldonload) {
            oldonload();
          }
          func();
        }
      }
    }
    
    
    
    
    addLoadEvent(function() {
      /* more code to run on page load */ 
    });
    
    Code (markup):
     
    fadetoblack22, May 7, 2009 IP
  2. koko5

    koko5 Active Member

    Messages:
    394
    Likes Received:
    14
    Best Answers:
    1
    Trophy Points:
    70
    #2
    I've PMed you pure JS code and here is jQuery:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>loadings</title>
    <script type="text/javascript" language="javascript" src="jquery-1.3.2.min.js"></script>
    <script type="text/javascript" language="javascript">
    $(document).ready(function(){
    $('input[type="button"]:eq(0)').click(function(){
    alert('bla');
    });
    $('input[type="button"]:eq(0)').trigger('click');
    });
    </script>
    </head>
    <body>
    <input type="button" value="Show message bla" />
    </body>
    </html>
    
    HTML:
    Regards
     
    koko5, May 7, 2009 IP
  3. fadetoblack22

    fadetoblack22 Well-Known Member

    Messages:
    2,399
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    160
    #3
    Can anyone else help me with this please. Will be paid on completion of task.
     
    fadetoblack22, May 8, 2009 IP
  4. JavaScriptBank.com

    JavaScriptBank.com Peon

    Messages:
    141
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
  5. hiteklife

    hiteklife Greenhorn

    Messages:
    11
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #5
    Give me a PM if you'd like. Usually with scripts that run on page load, it's simplest to write a function in the head of the page, and call it at the end. For example:

    That's probably the direction I'd start with. But like I say, if you need further help, I'd be glad to give it :)
     
    hiteklife, May 10, 2009 IP