473,699 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_i nner">
<font size="4" color="lightgre en" face="arial"><b ><i>
abc
</i></b>
</font>
</td>
</tr>
</table>

....
if I do in code :
current_page_in ner.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 8988
"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_i nner">
<font size="4" color="lightgre en" 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_in ner.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.getEle mentById("curre nt_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.getEle mentById("curre nt_page_inner") .childNodes[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_in ner 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.getEle mentById("curre nt_page_inner") .
getElementsByTa gName("*")[0]; // first non-text-node
while (elem.hasChildN odes()) { // remove content
elem.removeChil d(elem.lastChil d);
}
elem.appendChil d(document.crea teTextNode("bcd ")); // add new content
---
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.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
3972
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 nothing in IE. I'd be greatful for any assistance. Also, if I will have problems the code on Opera or Safari, I'd appreciate any pointers--I don't have a Mac to test Safari. THanks very much, Michael
18
2173
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 begs the question, what unit of measurement should we use for specifying font sizes, points or ems? Thanks. -Fleemo
5
27829
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 syntax for setting either font type or font size for a text box on a report. Does anyone know? Help. Please! dixie
1
1463
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 class to do so. My question is: When I write the message and I change the font to Verdana and change the color to blue the message recived to the" To Address" as text message without
14
3996
by: Roger Withnell | last post by:
How to I find out what size text the browser is set to? Thanks in anticipation.
1
6493
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" setting to be "E_ALL", notices are still not getting reported. The perms on my file are 664, with owner root and group root. The php.ini file is located at /usr/local/lib/php/php.ini. Any ideas why the setting does not seem to be having an effect? ...
8
11252
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 HeaderText="Subject" Text="Subject" DataTextField="Subject" DataNavigateUrlFields="Id" DataNavigateUrlFormatString="~/Templates/View.aspx?id={0}" HeaderStyle-CssClass="columnStyle" ItemStyle-CssClass="columnStyle" />
6
1962
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 the paragraphs change. Why? How can I stop it? I.E>
0
1313
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 user after selecting text will click a size. How do I achieve this? I know how to handle this when the selected text is written in a single font. I put the following code in the SelectedIndexChanged event of the combobox. private void...
0
8685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5869
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3054
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.