473,396 Members | 2,121 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DIV onload ?

55
Hi folks,

How can I do something as follows:

Expand|Select|Wrap|Line Numbers
  1. <div id='resultDIV' onload='funcX()'></div>
Here, I want to trigger funcX(), when some text is loaded in the div's innerHTML dynamically.

Through jquery I tried the following, but unsuccessfull.

Expand|Select|Wrap|Line Numbers
  1. $("#resultsDIV").load(function() {
  2.     alert("The div has been loaded.");
  3. });
best regards
Sep 1 '10 #1
3 22658
JKing
1,206 Expert 1GB
There is no onload event for divs

This is straight from the jquery site for the load()
"This event can be sent to any element associated with a URL: images, scripts, frames, iframes, and the window object."

I am sure there is an alternate solution for your problem if you could explain it with a little more detail.
Sep 1 '10 #2
You could implement something like JQuery to do this.
Sep 1 '10 #3
kovik
1,044 Expert 1GB
Since you are using jQuery, you can make use of their .bind() and .trigger() methods.

i.e.
Expand|Select|Wrap|Line Numbers
  1. <script>$(document).bind('divIsReady', function() {
  2.   alert('Div is ready');
  3. });</script>
  4.  
  5. ...
  6.  
  7. <div id="the-div">Content</div>
  8. <script>$(document).trigger('divIsReady');</script>
This is useful for when you need certain things to be handled before the rest of the page is loaded.
Sep 1 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Pai | last post by:
hello there, I am trying to rersize the window it works find in IE but doea not work with mozilla window.attachEvent(onload,MWSOnLoad); window.onload = function (MWSOnLoad) { alert('hello');...
6
by: Brian | last post by:
Hi everyone, I'm writing a function (in javascript) that needs to do one thing if the page has not loaded, and another (different) thing if the page has already loaded. I'm looking for a way...
4
by: David Virgil Hobbs | last post by:
My web host inserts banner ads into my html pages. The javascript in these banner ads interferes with the onload triggered javascript functions in my pages. Whether I trigger my javascript...
10
by: berg | last post by:
I'm trying to use the onload event to load a series of urls. What I find is that the onload function is only called one time no matter how large the array. Here is the onload function. var...
3
by: Liming | last post by:
Hi, Here is my situation. I have a textarea on the page. When the page loads, I need it to have some default text (which will be generated dynamically) so I did something like this ...
2
by: laredotornado | last post by:
Hello, I am looking for a cross-browser way (Firefox 1+, IE 5.5+) to have my Javascript function execute from the BODY's "onload" method, but if there is already an onload method defined, I would...
4
by: PJ6 | last post by:
Say I have serveral controls, all of which need to emit clientside script to execute on page load. They can't emit to OnLoad = <functionname> because then only one of the scripts will get executed....
3
by: Andrew Poulos | last post by:
I've been asked to add some additional code to HTML that get generated by a 3rd party program. Currently the code that gets generated already includes a window.onload = init; The program lets...
20
by: Mark Anderson | last post by:
Hi, I have this in an external JS library: ///////////////////////// function addMyEvent(){ var obj; if(document.attachEvent) { obj = document.getElementsByTagName('img'); for...
1
by: zebra242 | last post by:
I'm working to get the onLoad function of a javascript to work: the script allows form buttons in html to refer to labeled frames in flash. Which works fine. Now I want to add onLoad...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.