Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Javascript / Client Side Development

getElementById driving me crazy


the browser is firefox

the javascript:

function slideshowchecker(){

if(document.getElementById){alert('it works');}
slide = document.getElementById("slideX");

if(slide==null){
alert('yes2');

}
}

window.onload=slideshowchecker();

the document has a div id = slideX.
both alerts keep coming up.

here is the html

<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html><head><title>slideshow</title><script

src="jscripts/GTA.js" ></head><body><div class="slide" id="slideX">
grrrrrrrr

</div></body></html>

Why is slideX coming up null?

I'm really tired, I've been working from noon to 9 pm yesterday and
from 1 am to 5 am this morning.

On May 13, 5:40 am, pantag
oh wait, just realized, the script is executing before the div exists
so slide is null.

window.onload = slideshowchecker;

Don't use the call operator, when assigning functions to events.

If you need to pass the event:

window.onload = function(e) { alert('on' + e.type); }

If you need to pass arguments:

window.onload = function()
{
     func1('arg1', 'arg2');

<attempt to fix top post>
 > On May 13, 5:40 am, pantag
 > oh wait, just realized, the script is executing before the div exists
 > so slide is null.

What is "GTA.js?"  I ask only because I am a Grand Theft Auto fanatic.
If it has something to do with that, you must share.  :)

--
-Lost
Remove the extra words to reply by e-mail.  Don't e-mail me.  I am
kidding.  No I am not.

Thanks for the help, no actually it isn't Grand Theft Auto, sorry.
Hmm, maybe I should reconsider my acronym.

Cheers,
Bryan Rasmussen

On May 13, 6:09 am, -Lost <maventheextrawo@techie.com> wrote:

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc