Solved

onload without a body tag

Posted on 2010-09-01
10
487 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…
Suggested Courses

630 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