473,324 Members | 2,581 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,324 software developers and data experts.

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.

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

ruel <rasmussen.br...@gmail.comwrote:
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.

May 13 '07 #2
pantagruel wrote:
ruel <rasmussen.br...@gmail.comwrote:
>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();
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');
}
>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.
<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.
May 13 '07 #3
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.comwrote:
pantagruel wrote:
ruel <rasmussen.br...@gmail.comwrote:
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();

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');

}
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.

<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.

May 15 '07 #4

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

Similar topics

4
by: dont bother | last post by:
This is really driving me crazy. I have a dictionary feature_vectors{}. I try to sort its keys using #apply sorting on feature_vectors sorted_feature_vector=feature_vectors.keys()...
6
by: John Ramsden | last post by:
.... when the id 'junk' doesn't exist anywhere in the document, instead of returning 'object'?! I am using Javascript for a drop-down menu, slightly adapted from one by Angus Turnbull (see...
6
by: Keiron Waites | last post by:
Please see the problem in action here: http://www.leadbullet.biz/contact.php If you mouse over the fields, you will see that text is shown on the right. The text makes the other fields move when...
0
by: Shapper | last post by:
Hello, I have this code in Global.asax: Sub Session_Start(Sender As Object, E As EventArgs) Dim cookie As HttpCookie = Request.Cookies("MyCookie") If Not cookie Is Nothing Then...
12
by: bcr07548 | last post by:
I am writing a web site that uses JavaScript to validate certain forms and I seem to be having some trouble. The site uses PHP and for one of the forms, depending on the situation, one of of the...
5
by: Pupeno | last post by:
Hello, I am experiencing a weird behavior that is driving me crazy. I have module called Sensors containing, among other things: class Manager: def getStatus(self): print "getStatus(self=%s)"...
3
by: rashpal.sidhu | last post by:
Please help, this problem is driving me crazy !! I am using metaphone to create phonetic keys. When i run the module stand-a-lone it works fine. I'm trying to create a runner for informix...
5
by: mark4asp | last post by:
Every time the function below is called I get the alert. So I put a deliberate error in there and I check the value of (reportType=='MANDATE') in Firebug, which is found to be true. But still the...
2
by: kheitmann | last post by:
OK, so I have a blog. I downloaded the "theme" from somewhere and have edited a few areas to suit my needs. There are different font themes within the page theme. Long story short, my "Text Posts"...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.