...

View Full Version : getElementById is wierd



kyleschrama
06-03-2006, 07:34 PM
i've got this:

var calItem = document.getElementById('dynamicTable');
calItem.innerHTML="";

in an external javascript, and it was working fine. when i change dynamicTable from a tbody to a dl, i got "dynamicTable has no properties"
same thing if i tried to appendChild()

the wierdest part is that if i were to change my element id from dynamicTable to calItem, everything would work fine, as long as i had a html 4 doctype and if my doctype is xhtml, i get "calItem is not defined".

what gives?

v777tony
06-03-2006, 10:55 PM
Don't use a doctypes. They're retarded.

_Aerospace_Eng_
06-03-2006, 11:16 PM
Don't use a doctypes. They're retarded.
You have a lot to learn. Ever wonder why your pages look good in IE but like crap in Firefox? A doctype helps. Your pages have been invalid all this time. Let me guess you are probably one of those coders that codes for IE only because you don't know any better.

@kyleschrama Please post the rest of your code or post a link.

kyleschrama
06-04-2006, 12:14 AM
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript">
function getElement(){
var headItem = document.getElementById('header');
alert(headItem.innerHTML);
}

window.onload=getElement;
</script>
</head>
<body>

<h1 id="header">My header</h1>



</body>
</html>


here's the same problem, reproduced. the code i was having the problem with is really long, i wont post it.

if i take the contents of the function, and put it in a script element in the body, it works

EDIT: nevermind, that's working now. i'll keep playing with the code, but if anybody has any ideas of why it might not work, post em.

thanks,
kyle

_Aerospace_Eng_
06-04-2006, 12:36 AM
Only reason why it might not work is the element isn't created yet so you need to call the function onload because by then all elements will have been created.

kyleschrama
06-04-2006, 01:06 AM
window.onload=getElement;

i thought of that. it's just so confusing. thanks for the idea thought

Kor
06-05-2006, 01:56 PM
If you intend to code for strict XHTML, you may use the standard W3C DOM

headItem.firstChild.data

v777tony
06-13-2006, 01:07 AM
You have a lot to learn. Ever wonder why your pages look good in IE but like crap in Firefox? A doctype helps. Your pages have been invalid all this time. Let me guess you are probably one of those coders that codes for IE only because you don't know any better.

@kyleschrama Please post the rest of your code or post a link.

I don't know if there is a DOCTYPE for my page. I've tried all of them. But, if you can find one for this code below. I'll be happy


<html>
<head>
<title>The Andrew &amp; Andrew Show 104.7</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Content-Script-Type" content="text/javascript"/>
<meta http-equiv="Content-Style-Type" content="text/css"/>
<meta name="Author" content="Anthony L. Vanover II"/>
<meta name="Keywords" content="christian metal,christian heavy metal,christian death metal, christian metal radio,christian black metal,christian heavy metal music,christian metal music,104.7 fm,104.7 fm radio,104.7 fm radio station,104.7 fm the fish,104.7 1hit fm music station,104.7 fm music station,104.7 #1 hit fm music station,104.7 number 1 music station,broadcast,radio broadcast,live broadcast,live radio broadcast,fm broadcast,free radio broadcast,broadcast media,broadcast music,christian rock,christian rock music, christian rock radio,christian hard rock,christian punk rock, christian rock radio station,christian rock station,christian hit rock,christian alternative rock,hard rock christian music, christian rock hit,christian music rock,rock and roll christian music,top christian rock,rock,emo rock,emo style rock,hard rock,metal,hard metal,shazam,andrew,god,music,radio,radio station,radio music,radio station music"/>
<meta name="Description" content="The Andrew &amp; Andrew Show...richous mind-melting music that ROCKS!!!... The #1 Christian Metal station...Listen for the word SHAZAM!!! From Yuba City to Marrysville...9-10"/>
<meta http-equiv="Site-Enter" content="progid:DXImageTransform.Microsoft.gradientWipe(duration=2)"/>
<meta http-equiv="Page-Exit" content="progid:DXImageTransform.Microsoft.pixelate(duration=2)"/>
<script src="javascript\time.js"></script>
<script src="javascript\search.js"></script>
<script src="javascript\sound.js"></script>
<script src="javascript\load.js"></script>
</head>
<body onload="startTime();" bgcolor="#000000" text="#FFFFFF" link="#008000" vlink="#FF0000" style="cursor:url(cursors\cursorred.cur); SCROLLBAR-FACE-COLOR:#0000FF;SCROLLBAR-ARROW-COLOR:#FF0000;SCROLLBAR-3DLIGHT-COLOR:#FFFFFF;SCROLLBAR-DARKSHADOW-COLOR:#000000;SCROLLBAR-HIGHLIGHT-COLOR:#FFFFFF;SCROLLBAR-SHADOW-COLOR:#000000;SCROLLBAR-TRACK-COLOR:#008080;">
<div id="time" style="position:absolute; left:30px; top:15px; width:673px; height:0px; z-index:0" align="right" valign="top"></div>
<div style="position:absolute; left:30px; top:9px; width:666px; height:34px; z-index:0" align="center" valign="top">
<font style="font-size:16pt" color="#FFFFFF" face="BixAntiqueScriptHmkBold">The Andrew &amp; Andrew Show</font>
</div>
<hr size="3" width="679" style="position:absolute;left:24px;top:51px;width:679px;height:3px;z-index:1"/>
<div style="position:absolute; left:24px; top:41px; width:679px; height:27px; z-index:3" align="center" valign="top">
<embed src="sound\menu1.wav" name="navsound0" autostart="false" hidden="true" volume="100" width="0" height="0"/>
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" width="131" height="27"><a href="au.htm" onmouseover="playSound('navsound0')"><img style="cursor:url(cursors\cursorgreen.cur)" src="pic\1.gif" class="rollover pic\1_over.gif" alt="Learn our ways" align="top" border="0" width="131" height="27"/></a></td>
<td width="6"></td><td align="left" valign="top" width="131" height="27"><a href="cu.htm" onmouseover="playSound('navsound0')"><img style="cursor:url(cursors\cursorgreen.cur)" src="pic\2.gif" class="rollover pic\2_over.gif" alt="How to contact A&amp;A" align="top" border="0" width="131" height="27"/></a></td>
<td width="6"></td><td align="left" valign="top" width="131" height="27"><a href="ak.htm" onmouseover="playSound('navsound0')"><img style="cursor:url(cursors\cursorgreen.cur)" src="pic\3.gif" class="rollover pic\3_over.gif" alt="Learn about one of the hosts" align="top" border="0" width="131" height="27"/></a></td>
<td width="6"></td><td align="left" valign="top" width="131" height="27"><a href="aw.htm" onmouseover="playSound('navsound0')"><img style="cursor:url(cursors\cursorgreen.cur)" src="pic\4.gif" class="rollover pic\4_over.gif" alt="Learn about one of the hosts" align="top" border="0" width="131" height="27"/></a></td>
<td width="6"></td><td align="left" valign="top" width="131" height="27"><a href="ml.htm" onmouseover="playSound('navsound0')"><img style="cursor:url(cursors\cursorgreen.cur)" src="pic\5.gif" class="rollover pic\5_over.gif" alt="View time listings for broadcasted music" align="top" border="0" width="131" height="27"/></a></td>
</tr>
</table>
</div>
<div style="position:absolute; left:24px; top:95px; width:680px; height:256px; z-index:4" align="left" valign="top">
<table width="100%" height="100%" border="2" cellpadding="0" cellspacing="0">
<tr>
<td align="left" valign="top" width="676" height="252"><font style="font-size:14pt" color="#40E0D0" face="Times New Roman">Welcome,<br/>
Every Friday we (Andrew &amp; Andrew) broadcast richous mind-melting music that ROCKS!!! As Christians, we believe god should always be apart of our lives. We also love Rockin' music. So, we decided to broadcast good, wholesome, Christian METAL. Now a lot of the time you can't understand what the heck they're sayin'. So, we interpret it for you at the beginning of each song.</font>
<font style="font-size:8pt" color="#40E0D0" face="Times New Roman">*This Message is brought to you by The Andrew &amp; Andrew Show*<br/></font>
<font style="font-size:14pt" color="#40E0D0" face="Times New Roman">SHAZAM!!!<br/><br/></font>
<font style="font-size:12pt" color="#40E0D0" face="Times New Roman">The Andrew &amp; Andrew Show,<br/>
From Yuba City to Marrysville @ 9-10.<br/><br/>
Listen to the word SHAZAM!!! on 104.7.</font></td>
</tr>
</table>
</div>
<div style="position:absolute; left:25px; top:361px; width:678px; height:26px; z-index:2" align="left" valign="top">
<p/><font color="#FFFFFF" size="3" face="Courier New CE"><strong><marquee style="cursor:url(cursors\cursorred.cur)" bgcolor="#000000" height="26" direction="right" scrolldelay="1" scrollamount="4" behavior="scroll" align="top" loop="0">Site Made By <a href="av.htm" style="cursor:url(cursors\linkhand.cur)">Anthony L. Vanover II</a></marquee></strong></font>
</div>
<div style="position:absolute; left:25px; top:394px; width:678px; height:27px; z-index:5" align="left" valign="top">
<p/><font color="#FFFFFF" size="3" face="Courier New CE"><strong><marquee style="cursor:url(cursors\cursorred.cur)" bgcolor="#000000" height="27" direction="left" scrolldelay="1" scrollamount="4" behavior="scroll" align="top" loop="0">The #1 Christian Metal Show On 104.7</marquee></strong></font>
</div>
<div style="position:absolute; left:25px; top:430px; width:300px; height:0px; z-index:0" align="left" valign="top">
<font style="font-size:10pt" color="#FFFFFF" face="Times New Roman">
<p/>The Andrew &amp; Andrew Show offer you a search box from Google&copy; and Yahoo&reg;.
<p/>And guess what... you can use them both at the same time!
</font>
</div>
<div style="position:absolute; left:25px; top:430px; width:680px; height:0px; z-index:0" align="right" valign="top">
<form style="cursor:url(cursors\cursoryellow.cur)" action="javascript:DoSearch();" name="ToolBox" style="line-height: 2em;">
Enter search term(s): <input style="cursor:url(cursors\cursoryellow.cur)" type="text" name="SearchBox" size="22"/>
<br/>
<input type="radio" name="SearchOption" value="Google" onclick="document.ToolBox.SearchBox.focus()"/>Google
<input type="radio" name="SearchOption" value="Yahoo" onclick="document.ToolBox.SearchBox.focus()"/>Yahoo
<input type="radio" name="SearchOption" value="Both" onclick="document.ToolBox.SearchBox.focus()"/>Both
<br/>
<input type="submit" value=" Search " onmouseover="playSound('navsound0')" style="cursor:url(cursors\cursoryellow.cur)"/>
</form>
</div>
<div style="position:absolute; left:25px; top:520px; width:680px; height:0px; z-index:0" align="right" valign="top">
<font size="2"><b>Google&copy; and Yahoo&reg; are not &trade; 's of KCYC and/or The Andrew &amp; Andrew Show</b></font>
</div>
<div style="position:absolute; left:25px; top:520px; width:300px; height:10px; z-index:0" align="left" valign="bottom">
<a style="cursor:url(cursors\linkhand.cur)" href="lyrics.htm"><font style="font-size:10pt" face="Times New Roman">Get lyrics to broadcasted music</font></a>
</div>
<embed src="sound\Demon Hunter - Undying.mp3" autostart="true" loop="false" hidden="true" volume="100" width="0" height="0"/>
<script src="javascript\rollover.js"></script>
</body>
</html>

_Aerospace_Eng_
06-13-2006, 09:42 AM
I don't know if there is a DOCTYPE for my page. I've tried all of them. But, if you can find one for this code below. I'll be happy
Try this one

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
By the way some of your file paths are incorrect. In HTML file paths use / not \ so for example this

<script src="javascript\time.js"></script>
should be this

<script src="javascript/time.js"></script>
You do this in a lot more places on your page.

v777tony
06-14-2006, 04:08 AM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

This DOCTYPE didn't work, it looked the way it did last time in firefox.
(images are out of line & embed tags don't seem to work.)

_Aerospace_Eng_
06-14-2006, 04:16 AM
The images might be out of line, etc, etc but thats only because your code is bad. Run it through the validator http://validator.w3.org to see your errors. Did you even fix your image paths, they are incorrect. HTML uses / not \

v777tony
06-14-2006, 05:10 AM
The images might be out of line, etc, etc but thats only because your code is bad. Run it through the validator http://validator.w3.org to see your errors. Did you even fix your image paths, they are incorrect. HTML uses / not \

What about self-closing tags?

_Aerospace_Eng_
06-14-2006, 05:21 AM
Self closing tags are still / for example <br> in XHTML would be
<br />. Now that I see you are using XHTML try this doctype though I think you should try to get a better understanding of HTML first since you still seem to be using many old tags. Tables aren't for page layout either. They are to display data. Try this doctype.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

v777tony
06-14-2006, 05:56 AM
I used the xhtml doctype and ran it through the validation. It says that certain attributes don't exist or aren't specified. Also, embed tag dosn't exist.
and this other thingy:

Line 57, character 4: <p/>The Andrew &amp; Andrew Show offer you a search box from ...
Error: element p (http://www.htmlhelp.com/reference/html40/block/p.html) not allowed here; possible cause is an inline element (http://www.htmlhelp.com/reference/html40/inline.html) containing a block-level element (http://www.htmlhelp.com/reference/html40/block.html)

_Aerospace_Eng_
06-14-2006, 06:04 AM
A paragraph can't go inside of a font tag. Font is an inline element. A paragraph is a block level element. Embed has never been part of the standard which is why it says its invalid. Upload your page somewhere.

v777tony
06-14-2006, 06:12 AM
A paragraph can't go inside of a font tag. Font is an inline element. A paragraph is a block level element. Embed has never been part of the standard which is why it says its invalid. Upload your page somewhere.

My whole website?!&#191;&#161;
I need a place that supports M3U files(geocities doesn't) and a place that allows at least 102MB. And good file transfer(for music)

_Aerospace_Eng_
06-14-2006, 06:15 AM
Then work to fix the errors. I don't have time to fix your erraneous code or you can leave it like it is since you think doctypes are stupid anyways.

v777tony
06-14-2006, 08:00 PM
OK, I've been studying html in other pages. Then, I came to a conclusion that I needed more <div> tags. Everything is pretty much fixed.

But with this code:


<div style="position:absolute; left:50px; top:9px; width:777px; height:34px; z-index:0; font-size:16pt;" align="center" valign="top">
<h2><font color="#FFFFFF" face="BixAntiqueScriptHmkBold">About Us</font></h2>
</div>


IE drops the text 9 pixels off the top. Firefox drops the text from a spot below a margin of space off the top. So, Firefoxs' text appears lower than IE.

felgall
06-14-2006, 09:37 PM
Lean how to write (X)HTML and then you should be able to write pages that validate. If you write garbage then it wont validate and it will display as garbage in most web browsers. Only IE attempts to reconstruct a web page that is garbage.

The tag for emdedding objects into your page is <object> not <embed>.

<font> no longer exists although most browsers still try to interpret it because there are still a lot of 10 year old pages out there from back when it did exist.

(X)HTML defines the page content. You should use stylesheets to define the appearance (eg. fonts) and the layout (where things should go on the page).

v777tony
06-14-2006, 10:58 PM
well why doesn't the <object> tag work in firefox. It appears there but it plays no sound.

Just another Question:
For some reason the <marquee> tag doesn't work in Opera. why?

_Aerospace_Eng_
06-14-2006, 11:02 PM
You need to do some things in the object tag. Read this thread http://www.codingforums.com/showthread.php?t=82232
You probably shouldn't have hijacked this thread to begin with.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum