redho home | products | services
Web Design Forums

Web Design Forums  


Web Hosting, Web Design, Software and Web Development Forums  
 FAQFAQ   MemberlistArchive  Log inLog in   RegisterRegister 
         

how to make p str to be evaluated as html tag



 
Post new topic   Reply to topic    Web Design Forums -> JavaScript forum
View previous topic :: View next topic  
Author Message
kadamat



Joined: 01 Jun 2006
Posts: 88
How do I make '<p>' str to be evaluated as html tag ?
  Reply with quote


Peter Pitt



Joined: 20 May 2006
Posts: 114
Location: Egypt
document.createElement('p')
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
i do:
Var txt = document.createTextNode(str);
Comments.appendChild(txt);
  Reply with quote
Peter Pitt



Joined: 20 May 2006
Posts: 114
Location: Egypt
that's a textnode, I meant document.createElement()
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Should I create all markup as elements ?
My 'str' lookadamat like '<p> aaa <b>mmm</b>'
  Reply with quote
Peter Pitt



Joined: 20 May 2006
Posts: 114
Location: Egypt
then instead, use .innerHTML
Comments.innerHTML=str;
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
that's not working for me in IE
  Reply with quote
Peter Pitt



Joined: 20 May 2006
Posts: 114
Location: Egypt
It should
Smile
Depending on what 'comments' may be
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
It's <div>
  Reply with quote
Roombor



Joined: 02 Jun 2006
Posts: 111
You should indeed create all markup as elements. The DOM is the way forward. :)
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Roombor, will it work if add it later to var txt = document.createTextNode(str); ?
I mean is it valid to add object as input for TextNode ?
  Reply with quote


Roombor



Joined: 02 Jun 2006
Posts: 111
kadamat, I'm not sure what you mean.
A text node is just something which contains a bunch of text. So the argument for createTextNode is always a string.
If you want to create all sorts of complicated formatting for your string I will grudgingly admit that innerHTML might be better. For example document.addTextNode('This text is <strong>bold</strong>') shouldn't work.
  Reply with quote
kadamat



Joined: 01 Jun 2006
Posts: 88
Thankadamat for help
  Reply with quote
Page 1 of 1
Post new topic   Reply to topic    Web Design Forums -> JavaScript forum


Dubai Forums - Expat Help | Vegan Chat | Java Programming | Free 3D tutorials and 3d textures | Paris Forum | EU Forum
Free Dubai Classifieds | Free London Classifieds | Jobs in London

High Quality, Custom 3d animation and Web Design solutions Royal Quality Web Hosting Services Vegetarian and Animal Rights news

Powered by phpBB © 2001, 2005 phpBB Group