kals84
October 18, 2011, 9:58am
1
hi,
i have a problem with innerHTML
if i wrote
document.getElementById(‘someid’).innerHTML = “ok”;
then it wroks
but when i wrote
document.getElementById(‘someid’).innerHTML = “<sometext> ok”;
it does not work.
i.e. <sometext> is not visible
if check on firebug / dom it display…
<sometext> ok </sometext>
please help…
how do i print / display above string as it as.
you may download file or check below link…
please click here
The problem is the page thinks your posting an HTML element, to avoid this you will need to convert the string so < and > for example get converted to HTMLEntities. See the following link for a quick and painless way to do this:
kals84
October 18, 2011, 12:10pm
3
this might not work… in above case <b> or <i> or <font> tags does not work.
Alex69
October 18, 2011, 12:45pm
4
if you want “<sometext>” to be visible, then use .innerText instead of .innerHtml