Displaying strings in italics using javascript

2k Views Asked by At

I am using a multiline text in xul and in I need to display a string. however part of the string needs to be in italics and if a use the .italics() method in javascript all that's displayed is the Blink! tags next to the string. Is there another way to make the string italics using javascript?

2

There are 2 best solutions below

2
On
  1. String.prototype.italics() just wrap the text with <i> and </i>, this only works in HTML not XUL.
  2. When you say 'a multiline text', are you reference to <textbox> element in XUL? If so this wrapper doesn't work with rich text. try some other element to contain your text.
0
On

I am not positive if this works on a XUL-document, but you could try the style-object:

document.getElementById("myString").style.fontStyle = "italic";