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):
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
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