473,473 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

GetElementByID nog working for DIVs in Firefox?

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>
Jul 19 '06 #1
2 1628
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?
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)
DIV (and SPAN) elements don't have a name attribute.

Use:

msg = 'getelementbyid(menu): ' + divm.getAttribute('name')

to access the non-standard attribute.

The style attribute doesn't have an invisibility attribute either, but I
dare say you'll figure that out.
Jul 19 '06 #2
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.
Jul 19 '06 #3

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

Similar topics

6
by: MNF | last post by:
Hi everyone, I am using document.getElementById function in JavaScript to find a control within an html body, but instead I get back META item, because incidently the name of one meta tags is the...
15
by: lawrence | last post by:
Sorry for the dumb question but I'm new to Javascript. I wrote this script hoping to animate some div blocks on a page. You can see the page here: http://www.keymedia.biz/demo.htm Can anyone...
3
by: InvisibleMan | last post by:
Thanks in Advance for any help on this - its truely sending my head in loops... so I appreciate your efforts! okay, I have a javascript listed below that drops down submenus contained within:...
4
by: the other john | last post by:
I came across a third party script I want to learn how to configure as well as learn more dhtml in the doing. I'm not much of a JS guy yet but I'm working on it. This script works fine in IE6...
4
by: gtalmes | last post by:
I am writing a pretty simple Javascript which makes use of getElementById to work with some divs on the page. The divs are labelled correctly (id="whatever") and there are no duplicate div ids. ...
10
by: Nik | last post by:
Hello! Thanks for reading my question first! I have many divs with an numeral id ,for example <div id="999">...</div>, <div id="1000">...</div> and I wish to do something like this, for(...
3
by: djp1988 | last post by:
I have made up a code allowing users to click on a tab and show content in a neat white box, similar to what yahoo have on their homepage. I have used 5 divs, all but one set to display:none and...
8
by: cyqotiq | last post by:
First, let me state that this is not necessarily a Firefox problem, as I haven't fully tested in IE just yet. Second, let me state that this is not the typical "getElementById not working Firefox"...
3
by: GarryJones | last post by:
The following works in MSIE but not firefox. I suspect it has something to do with the fact that the element I am trying to access is not the "tid" which is the name of the DIV that is passed to...
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,...
1
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.