Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

onload event

Status
Not open for further replies.

dwhalen

Programmer
Feb 22, 2002
105
CA
Hello,
I am having problems with users clicking on links before everything has loaded. This causes a problems if the link refers to a form that has not been printed out yet and cause a javascript error.

What I want to know is, if I set somthing to fire onload for the body ' <body onload=&quot;allowClicks()&quot;> ' will that fire only when the entire page has been printed out? If not, then what object will fire the onload event only when the entire page has loaded? I mean even external elements like js files.

thanks
 
You could give each of your links a unique id and no href and then load the links with an onLoad event...

<script>
function loadLinks(){
thisLink = document.getElementById(&quot;link1&quot;)
thisLink.setAttribute(&quot;href&quot;,&quot;page2.html&quot;)
thisLink.setAttribute(&quot;target&quot;,&quot;_blank&quot;)
linkLabel = document.createTextNode(&quot;Go Here&quot;)
thisLink.appendChild(linkLabel)

thisLink = document.getElementById(&quot;link2&quot;)
thisLink.setAttribute(&quot;href&quot;,&quot;javascript: doFunction()&quot;)
linkLabel = document.createTextNode(&quot;Do this&quot;)
thisLink.appendChild(linkLabel)
}
</script>

<body onLoad=&quot;loadLinks()&quot;>
<a id=&quot;link1&quot;></a>
<a id=&quot;link2&quot;></a> Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
Yeah,

Thanks for your suggestion, which is a good idea, but I am working with a web application that has hundreds and hundreds of links and probably over 1000 files. I am working with software that has been in development for years so, I am constrained by the orginal design and code.

I do have one function that prints out the top of every html page from a perl file. So that is why I am wondering if the onload of the body fires only when the page is completely loaded. This way I can setCapture() at the top of the page and not allow the user to click on anthing, and then when onload fires, realaseCapture().

Later
 
Yes, the onLoad event only fires after the entire page is loaded.

Good luck Get the Best Answers! faq333-2924
Is this an asp FAQ? faq333-3048

mikewolf@tst-us.com
 
You could always set a boolean variable as false at the beginning of the page, and at the end of the page set it as true. Then it would have to wait until everything else is loaded before it would let them clickthrough. I've used that a lot for the same purpose
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top