473,396 Members | 2,038 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.

same code 3 places, 1 doesn't work

Hello, I have a web app up at http://niceguy.wustl.edu/NEISGEI/EmisComp

The relative code I'm talking about is the loading image that is
displayed when a request is made, and disappears when the request is
fulfilled.

Now, I got this code from somewhere, and it works beautifully except
for one spot.

There is a div for each loading image. Here's the code for the first:

function addLoadEvent1(func) {
if (window.onload){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}else{
window.onload = function() {
if (oldonload) {
oldonload();
}
func();}
}
}
}

addLoadEvent1(function() {
document.getElementById("loading1").style.display= "none";
});
The second and third functions are exactly the same (addLoadEvent2,
getElementById("loading2"), etc.).

Now, the first two loading images correctly disappear when the images
are finished loading, however the third remains....

Also as an interesting sidenote, when I add an alert("test") or
something to the addLoadEvent1() call, right before the
document.getElement..display=none, the alert doesn't pop up. This
section of the code doesn't get read.

Again, the first two work perfectly.

I hope I didn't make this sound too complicated. If anyone has any
questions I'll respond ASAP. Any ideas and I would be greatly
appreciative.

Thanks!

May 29 '07 #1
3 1235
You probably have an error, like there is no div (or more than one)
with the ID "loading2".

I suggest using Firebug: http://www.getfirebug.com and opening the
console, so you can see any errors that might appear and/or use the
shell to inspect what's going on.

Also, you should credit Simon Willison for the code he wrote:
http://www.dzone.com/r/simon_williso...loadevent.html

On May 29, 3:14 pm, edfialk <edfi...@gmail.comwrote:
Hello, I have a web app up athttp://niceguy.wustl.edu/NEISGEI/EmisComp

The relative code I'm talking about is the loading image that is
displayed when a request is made, and disappears when the request is
fulfilled.

Now, I got this code from somewhere, and it works beautifully except
for one spot.

There is a div for each loading image. Here's the code for the first:

function addLoadEvent1(func) {
if (window.onload){
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}else{
window.onload = function() {
if (oldonload) {
oldonload();
}
func();}
}
}

}

addLoadEvent1(function() {
document.getElementById("loading1").style.display= "none";

});

The second and third functions are exactly the same (addLoadEvent2,
getElementById("loading2"), etc.).

Now, the first two loading images correctly disappear when the images
are finished loading, however the third remains....

Also as an interesting sidenote, when I add an alert("test") or
something to the addLoadEvent1() call, right before the
document.getElement..display=none, the alert doesn't pop up. This
section of the code doesn't get read.

Again, the first two work perfectly.

I hope I didn't make this sound too complicated. If anyone has any
questions I'll respond ASAP. Any ideas and I would be greatly
appreciative.

Thanks!

May 29 '07 #2
Hey Joe, thanks for the help. I got firebug, which is really nice,
but I can't seem to find any errors anywhere. There is definitely
only one div with id="loading2". There are no javascript errors or
anything that pops up in the console.

I'm totally out of ideas.

Also, I got Simon's code through a middle-man internet page and did
not know the original author. I have added credit to Simon for his
extremely useful code.

Any other ideas?
Thanks!
-Ed

May 30 '07 #3
Still looking for a bit of help on this one. :(

Anyone?
-Ed

Jun 5 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Timo J | last post by:
Hi - I cant fins the right way to put this problem.. I have a structore wich is like this.. www.thewebsite.dk/images/ And from a dir www.thewebsite.dk/something/somethingelse/test.php...
2
by: Skip Montanaro | last post by:
At work we have a package structure for our homegrown code. Developers each have their own sandboxes where they work on the stuff they are responsible for (mixtures of C++ libraries, SWIG wrappers...
5
by: Alan Mackenzie | last post by:
I've recently moved onto a C++ project with a large number of directories (several hundred) containing an even larger number of C++ source files. There are vastly more ways in C++ to obfuscate a...
6
by: CJ | last post by:
Okay, same program, different issue. Thanks to the help that I was given I was able to complete my program to find variables in a list that were repeated, and display them once, and how many times...
10
by: Brian W | last post by:
Hi All, I have a web user control that, among other things, provides Print this page, and Email this page functionality I have this script that is to execute on the click of the asp:hyperlinks ...
21
by: Chris Durkin | last post by:
I've got an ASP.NET website on my local box, set to compile to bin\Debug and bin\Release in debug and release modes. Both directories are populated with dlls, as the solution has been compiled in...
4
by: Hank | last post by:
Hello, I'm running Access 2000. I would like to know if its possible to use VBA code to determine how many decimal places are specified for each table field. Currently I loop throught the...
1
by: JM | last post by:
I'm studying for webdeveloper. The trainer only comments when it doesn't work, but I am also interested in comments on programs or pieces of code that work : can it work better, faster, shorter,...
20
by: subramanian | last post by:
Hello I have a doubt in the following piece of code: int a; printf("a=%p\n", a); printf("&a=%p\n", &a); these printf statements print the same value for both 'a' and '&a". I tried in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.