Solved

onload without a body tag

Posted on 2010-09-01
10
483 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
  • 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
Independent Software Vendors: 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

685 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