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

Firefox issues inserting text into span element

I'm having trouble pre-filling information into html <span> elements
using javascript, just with Firefox. IE seems to work fine.
I'm using the following:

<script language='JavaScript'>

document.getElementbyid("lblText").innerText = 'test';

</script>

<span id='lblText'></span>

Can someone please suggest other ways I could do this?

May 26 '06 #1
2 8310
ddolheguy wrote:
I'm having trouble pre-filling information into html <span> elements
using javascript, just with Firefox. IE seems to work fine.
I'm using the following:

<script language='JavaScript'>
The language attribute is deprecated, type is required:

<script type="text/javascript">

document.getElementbyid("lblText").innerText = 'test';
innerText is an IE invention, it is not supported by Firefox (or most
other browsers). If you are writing simple content, and wish to
completely replace what is already there, then you can use the
non-standard but widely supported innerHTML:

document.getElementbyid("lblText").innerHTML = 'test';
For more complex stuff, you should probably use DOM methods.

</script>

<span id='lblText'></span>


You should have the element before the script, it will almost certainly
error anyway because when the script runs, the element hasn't been
created yet.
--
Rob
May 26 '06 #2
ddolheguy wrote:
I'm having trouble pre-filling information into html <span> elements
using javascript, just with Firefox. IE seems to work fine.
I'm using the following:

<script language='JavaScript'>

document.getElementbyid("lblText").innerText = 'test';

</script>

<span id='lblText'></span>


As was mentioned, using innerText is not always going to work.

So, just use:

document.getElementById("lblText").appendChild(doc ument.createTextNode("test"));

May 26 '06 #3

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

Similar topics

3
by: davidkarlsson74 | last post by:
Error: document.getElementById("folderMenu").cells has no properties File: http://www.volkswagen.se/tillbehor/js/foldermenu.js Rad: 49 The function activates different DIV:s, but doesn't seem to...
12
by: VK | last post by:
http://www.mozilla.com
1
by: KPS | last post by:
I'm attempting to create a simple treeview-like behavior in JavaScript. The desired behavior happens in IE but I cannot get the same to happen in FireFox. The primary thing I want to accomplish...
12
by: shafiqrao | last post by:
Hello everyone, I have a script that runs in IE great, but in firefox it has problems. I understand that there are some objects that are accessed differently in IE and Mozilla. Can anybody let...
1
by: richardsayre | last post by:
I am making a spell checker. The reqest sends out the text and gets back HTML of the suggestions and misspelled words. When you click on a misspelled word the suggestion list pops up and you can...
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...
2
by: jdvictor | last post by:
Understandably I know that the real issue is in IE but at the moment everything looks good in IE and not Firefox. THE PROBLEM The problem that I am having is that my navigation menu is out of...
1
by: littlealex | last post by:
IE6 not displaying text correctly - IE 7 & Firefox 3 are fine! Need some help with this as fairly new to CSS! In IE6 the text for the following page doesn't display properly - rather than being...
3
by: SAL | last post by:
Hello, I did google this issue and found some stuff related to BrowserCaps section of either web.config or machine.config but it didn't work. It seems that most pages in my webapp are okay but a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.