Solved

onload without a body tag

Posted on 2010-09-01
10
484 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 500 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

751 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