Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

onload without a body tag

want to do
onload
without using a body tag

or just load a javascript when I reach a section of the page

Avatar of aqif_g
aqif_g

just write javascript at that portion of page where you want it to execute while loading.

Suppose you want it to execute after a div tag with id='pre' and before a div with id='nxt';

you can write it like.

regards,
aqif

<div id='pre'>Html goes here</div>
<script type='text/javascript'>
coding goes here
</script>
<div id='nxt'>Html goes here</div>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
anythign in onload will executes 'after' complete LOADING of the page... whereas writing code inside the HTML executes 'during' loading of page.
@agif_g, check other @rgb192 question, the current goal is to show a textarea depend the selected option of a dropdown box.
Maybe it will put your inline code before the selectbox or another object(s) he want to initialize.
Maybe it -> he

sorry :)
@leakim971: I didn't ment that you are wrong. I was just adding the difference between two answers. This is an important point to keep in mind while using anyone of them.

In some cases,

if you want to display a popup after complete loading of a page. You can't use my method to do that, and if you want to do some calculations or changes just before a specific part loads, then onload will fails.

I was trying to clear this. I didn't meant that you are wrong.

regards,
aqif
Avatar of rgb192

ASKER

thanks
No worries @aqif_g, I'm for peace, have a good life and a lot of fun. Sorry if you think that I was agressive or something like that, it's not my temperament.

@rgb192, you're welcome! Thanks for the points!
its alright leakim971. congrats :)