/    Sign up×
Community /Pin to ProfileBookmark

Where do I place an "onload" accessed function?

I have a common page for the common body of many of my pages.
This page contains the <body> part: layout, links etc.
One of the files needs a javascript function that is accessed at “onload”. This function would normally reside in the body tag.

I tried putting it in the head but it won’t work.
I tried many variations but they don’t work.
Where should I put the onload function so it will be accessed correctly?
I could of course write a separate page for it, but there probably is a better way.
Thanks.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@mityaAug 04.2009 — Put this in the head

[CODE]window.onload = function() { name_of_my_function(); }[/CODE]
×

Success!

Help @RoxyBoo 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 4.29,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...