473,320 Members | 1,766 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,320 software developers and data experts.

setting text, change the font

Hello,

Suppose I have a table like this :

<table width = "580">
<tr align = "right" width = 760>
<td id = "current_page_inner">
<font size="4" color="lightgreen" face="arial"><b><i>
abc
</i></b>
</font>
</td>
</tr>
</table>

....
if I do in code :
current_page_inner.children(0).innerText = "bcd"
the text is changed to the new text,
and the font doesn't change,
but the font is not italic and not bold as the original.
Why ?

Thanks :)
Jul 20 '05 #1
1 8974
"Mr. x" <a@b.com> writes:
Suppose I have a table like this :

<table width = "580">
<tr align = "right" width = 760>
<td id = "current_page_inner">
<font size="4" color="lightgreen" face="arial"><b><i>
abc
</i></b>
I recommend against using the font, b and i tags. Use CSS to get
the same effect, that is what it was invented for.
</font>
</td>
</tr>
</table>
...
if I do in code :
current_page_inner.children(0).innerText = "bcd"
Amazing, out of the three parts of the expression on the left of
the equal sign, all are IE-specific and won't work in Mozilla.

It is bad style to refer to an element by using its name as a global
variable (bad style, and not likely to work in many browsers, including
Mozilla).
Use the W3C DOM method "getElementById" instead:
document.getElementById("current_page_inner")

The children collection is not standard code. Again, it probably works
in IE, but doesn't in Mozilla/Netscape 6+. Use the W3C DOM "childNodes"
collection instead:

document.getElementById("current_page_inner").chil dNodes[0]

Likewise "innerText" is a proprietary MS property that doesn't work in
Mozilla. The W3C method isn't as short, so I won't show it here.
the text is changed to the new text,
and the font doesn't change,
but the font is not italic and not bold as the original.
Why ?


Because the first child of the element named current_page_inner is the
font tag (in IE, in Mozilla it is a text node containing the newline
between the td and the font elements). You set the innerText of the
font tag to "bcd". That clears *all* the content of the font tag and
adds a single text node with the text "bcd".

It is equal to this W3C DOM code (ok, I will show it here :)

---
var elem = document.getElementById("current_page_inner").
getElementsByTagName("*")[0]; // first non-text-node
while (elem.hasChildNodes()) { // remove content
elem.removeChild(elem.lastChild);
}
elem.appendChild(document.createTextNode("bcd")); // add new content
---
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

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

Similar topics

21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
18
by: fleemo17 | last post by:
My organization is developing a set of "standards" for websites built inhouse. The first question that comes to mind is what would be a good standard default size for <p> text? 12 point? Which...
5
by: dixie | last post by:
I want to be able to set the font size and font type for text in a text box on a report using VBA. I wan't to be able to control it from a setting in a table. The problem is that I don't know the...
1
by: Husam | last post by:
Hi EveryBody: I am doing windows application project by using Vb.Net. The function of this project is to send e-mail by adding system.web.dll as refrance to my project and using system.web.mail...
14
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
1
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 on Apache 2 on Fedora Core 5. PHP was installed using Apache's apxs and the php library was installed to /usr/local/php. However, when I set my "error_reporting"...
8
by: Jeff | last post by:
ASP.NET 2.0 I'm wondering how to set the color of a visited HyperLinkField (the link text) in a GridView?? Here is the markup of the HyperLinkField I have problems with: <asp:HyperLinkField...
6
by: Steve | last post by:
I have a div with two - three paragrahs in it. Each paragraph has its own inline style tag with its own font size setting. When I set the last paragraph's font size the font sizes for ALL of...
0
by: babai28 | last post by:
Hi there! I have a rich text box and in the formatting toolbar (that sticks to its upper border) I have a ComboBox that displays the standard Font sizes. Just like it is in MS Word or Excel. The...
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
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: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.