bleustreak12 Posted October 14, 2010 Share Posted October 14, 2010 Hi, I have some effects right now which come up only when someone clicks on a Hyperlink or a button. I want the same thing to happen when the page loads automatically without somebody clicking on the link. How can I run a button or a hyperlink on body onload function(i.e when page loads). Is there any other way to run a link or button when page loads can you provide me examples Quote Link to comment https://forums.phpfreaks.com/topic/215865-running-links-and-buttons-automatically-when-page-loads/ Share on other sites More sharing options...
jcanker Posted October 14, 2010 Share Posted October 14, 2010 That all depends on what you want to happen, exactly. What is it that the button does, for instance? Have you tried taking the onClick results (e.g. what happens when you click the button) and applying them in a script in the onload section? You can also use jQuery and run it inside a script tag and $(document).ready(function(){ //fire the jQuery events here }; Using that method will wait until the page is finished loading first before firing the events so that you don't get unexpected results or modify something that technically doesn't exist in the page yet. If you use onLoad and modify content you run the risk of trying to modify stuff the browser doesn't know about yet.. Quote Link to comment https://forums.phpfreaks.com/topic/215865-running-links-and-buttons-automatically-when-page-loads/#findComment-1122244 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.