/    Sign up×
Community /Pin to ProfileBookmark

window.onload trouble

hi all:

im currently using window.onload to initiate my functions but cause the functions only load when the entire page loads i get broken links cause return false wasn’t read, is there anyway to load functions as soon as the page starts loading, since im using it on a side nav bar it takes very little time for the elements to load n they r on a seperate page linked by SSI.

Thx all…

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@Declan1991Mar 22.2008 — Right underneath the last link, put [code=html]
<script type="text/javascript">preInit();</script>[/code]

Use preInit then for your functions. In fact you are better off to put your scripts at the end of the page, instead of the top. It will load faster, as it loads progressively, and parses Javascript as it finds it.

Equally, you should redesign your links so that they are not broken without Javascript. Remember that maybe up to 10% of your visitors, will not have Javascript enabled. If you post the type of links, we can see could we help you do that.
Copy linkTweet thisAlerts:
@TaboMar 22.2008 — Right underneath the last link, put [code=html]
<script type="text/javascript">preInit();</script>[/code]

Use preInit then for your functions. In fact you are better off to put your scripts at the end of the page, instead of the top. It will load faster, as it loads progressively, and parses Javascript as it finds it.

Equally, you should redesign your links so that they are not broken without Javascript. Remember that maybe up to 10% of your visitors, will not have Javascript enabled. If you post the type of links, we can see could we help you do that.[/QUOTE]

A whole 10%!? are you sure? That sounds a bit big to me...
Copy linkTweet thisAlerts:
@NINJA_WBauthorMar 22.2008 — ill look in to that thx for replys... i have for the moment removed the href attribute n used the name attribute instead so that even if the script is not loaded the link will not be broken. But however thes wont do it for ppl with script turned off ?...
Copy linkTweet thisAlerts:
@Declan1991Mar 23.2008 — A whole 10%!? are you sure? That sounds a bit big to me...[/QUOTE]
Depends on the community you are dealing with, but I think that that is a pretty normal average. Especially if you are dealing with those who use alternative browsers to IE, and those who know what Javascript is. Maybe for your less computer literate user, you could knock that down, but even so, there are a good few users with it turned off.
Copy linkTweet thisAlerts:
@lAZLfMar 23.2008 — if u r worried about people not having javascript then do what i do. what i do is: when the window loads i redirect the user to a page (that uses your javascript) using javascript. if the user doesnt have javascript then he'll stay on the current page. http://screenbreaker.com/ uses that same method.
Copy linkTweet thisAlerts:
@Angry_Black_ManMar 23.2008 — the non javascript version of that site doesnt look like it loads right..
Copy linkTweet thisAlerts:
@Declan1991Mar 23.2008 — if u r worried about people not having javascript then do what i do. what i do is: when the window loads i redirect the user to a page (that uses your javascript) using javascript. if the user doesnt have javascript then he'll stay on the current page. http://screenbreaker.com/ uses that same method.[/QUOTE]
BTW, I completly disagree. I strongly believe that a page should function fully without Javascript, and should be enhanced by unobtrusive JavaScript that runs after page load (by having it the last thing in a page so that it is NOT parsed until the page has fully loaded).
×

Success!

Help @NINJA_WB spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...