Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > GetElementByID nog working for DIVs in Firefox?

Reply
Thread Tools

GetElementByID nog working for DIVs in Firefox?

 
 
Jan Doggen
Guest
Posts: n/a
 
      07-19-2006
Hello,

The following code displays the name for all three elements in IE, but fails
for the1st and 3rd in Firefox.
What could be going on?
I tried SPAN instead of DIV doesn;t work either.
(What I finally want is to set style.invisibility for the text in that DIV)

TIA
Jan

<HTML>
<BODY onload="Init()">

<script type="text/javascript">
function Init()
{
if (document.all)
var msg = 'document.all OK'
else
var msg = 'document.all N/A';

if (document.getElementById)
alert(msg + '\ndocument.getElementById OK')
else
alert(msg + '\ndocument.getElementById N/A');

var divm = document.getElementById("menu");
if (divm)
msg = 'getelementbyid(menu): ' + divm.name
else
msg = 'getelementbyid(menu): N/A';

var ff = document.getElementById("varProfBevoegdheden");
if (ff)
msg = msg + '\ngetelementbyid(varprofbevoegdheden): ' + ff.name
else
msg = msg + '\ngetelementbyid(varprofbevoegdheden): N/A';

var divi = document.getElementById("bvtext");
if (divi)
msg = msg + '\ngetelementbyid(bvtext): ' + divi.name
else
msg = msg + '\ngetelementbyid(bvtext): N/A';

alert(msg);
}
</script>


<div id="menu" name="menu">
<table>
<tr><td>Zoeken 1</td></tr>
<tr><td>Zoeken 2</td></tr>
</table>
</div>


<table>
<tr>
<td>
<div id="bvtext" name="bvtext">Bevoegdheid:</div>
</td>
<td>
<select id="varProfBevoegdheden" name="varProfBevoegdheden" size="4">
<OPTION VALUE="1">Geen voorkeur\n.v.t.
<OPTION VALUE="2">1e graads
<OPTION VALUE="4">2e graads
</select>
</td>
</tr>
</table>

</BODY>


 
Reply With Quote
 
 
 
 
Richard Cornford
Guest
Posts: n/a
 
      07-19-2006
Jan Doggen wrote:
> The following code displays the name for all three elements
> in IE, but fails for the1st and 3rd in Firefox.
> What could be going on?


The first and third elements are DIV elements and DIV elements do not
have NAME attributes in HTML. Firefox is representing this truth by not
creating non-standard properties of these element for any NAME
attributes included in the mark-up for those elements (and any other for
which NAME attributes are not defined), while IE transfer just about any
attribute's value defined in the HTML onto a property of the
corresponding element.

> (What I finally want is to set style.invisibility for the
> text in that DIV)


You have successfully retrieved references to the elements using their
ID attributes so setting properties of their - style - objects should
not be a problem.

Richard.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
the document.getElementById() tag is not working in javascript. adiraju_anuradha Java 0 11-08-2012 07:45 AM
document.getElementById stopped working after adding an iframe AC Javascript 11 07-01-2008 12:16 PM
swapping divs -- when divs NOT positioned absolutely.. maya Javascript 4 11-16-2007 05:11 PM
Managing divs within divs.... rich HTML 0 02-02-2006 07:38 PM
How to show an image where height nog greater then xx but do not stretch Roland Wolters ASP General 2 12-04-2003 10:21 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57