Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

onload without a body tag

Posted on 2010-09-01
10
Medium Priority
?
490 Views
Last Modified: 2013-11-11
want to do
onload
without using a body tag

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

0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 3

Expert Comment

by:aqif_g
ID: 33582757
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

0
 
LVL 82

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 33582839
Another way :


<script language="javascript">
   window.onload = function() {
       init1();
       event2();
       do_something3();
   }
</script>
<body>
<select>
....

Open in new window

0
 
LVL 3

Expert Comment

by:aqif_g
ID: 33582857
anythign in onload will executes 'after' complete LOADING of the page... whereas writing code inside the HTML executes 'during' loading of page.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 82

Expert Comment

by:leakim971
ID: 33582893
@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.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33582896
Maybe it -> he

sorry :)
0
 
LVL 3

Expert Comment

by:aqif_g
ID: 33582944
@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
0
 

Author Closing Comment

by:rgb192
ID: 33582949
thanks
0
 
LVL 82

Expert Comment

by:leakim971
ID: 33582971
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.

0
 
LVL 82

Expert Comment

by:leakim971
ID: 33582974
@rgb192, you're welcome! Thanks for the points!
0
 
LVL 3

Expert Comment

by:aqif_g
ID: 33582983
its alright leakim971. congrats :)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question