By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,606 Members | 3,832 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,606 IT Pros & Developers. It's quick & easy.

Trigger a function after the page is fully loaded

100+
P: 258
[MOD: Moved from the PHP forum. --pbmods]

Hi everyone
Actually I'm not sure if I have to post this question in PHP forum.
I have a page (download page) which contains a link but I want the link to be invisible until the page is fully loaded.
The reason is that if the link apears at the begining then the user will click on it to download the file and then close the window before banners are loaded and it would not be counted as a page view on google adsense.
So I need to have an invisible link which apears when the page is fully loaded.
I'v seen this before on other websites but don't know how to do it. I think I'm gonna need a JAVA function or something.

Any suggestions will be appreciated

regards
Oct 13 '08 #1
Share this Question
Share on Google+
5 Replies


joedeene
100+
P: 583
What about something like <body onload="myfunction()"> ? And give your function some kind of action to show the link?

joedeene
Oct 14 '08 #2

100+
P: 258
Thanks joedeene
You solved my problem. I wasn't sure if ONLOAD runs the function when the HTML is loaded or after loading the whole page.
It seems to work fine now.
Here is what I used:

Expand|Select|Wrap|Line Numbers
  1. <body onload="objectid.style.display='block'">
  2. <a id="objectid" href="www.example.com" style="display:none">something</a>
  3. </body>
  4.  
Thanks again
Oct 14 '08 #3

acoder
Expert Mod 15k+
P: 16,027
That won't work in most browsers, at least in strict mode.

Use document.getElementById() to access an element. The ID doesn't make it accessible in the global namespace.
Oct 14 '08 #4

100+
P: 258
That won't work in most browsers, at least in strict mode.

Use document.getElementById() to access an element. The ID doesn't make it accessible in the global namespace.
Thanks for the help acoder
I really appreciate it :)
Oct 14 '08 #5

acoder
Expert Mod 15k+
P: 16,027
No problem, you're welcome :)
Oct 14 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.