empty P tags and linebreaks

A

allie

I have a problem with inconsistency in IE browser, looking at the
innerHTML property and the actual contents.

I used this in a plain HTML page:

<div contenteditable="true" style="border:solid 1px black"
onblur="alert(this.innerHTML)">
</div>

If you type content with an extra linebreak, and press TAB to leave the
field, you see for example:
<p>a</p>
<p>&nbsp;</p>
<p>b</p>

Note that if you use the cursor to browse the DIV, you do NOT see
actually a space for the second line, there is in fact no space, it is
a empty line.

But if you place exactly this same content inside the editable DIV,
like this:

<div contenteditable="true" style="border:solid 1px black"
onblur="alert(this.innerHTML)">
<p>a</p>
<p>&nbsp;</p>
<p>b</p>
</div>

and then reload your page, then suddenly you DO see the space. How can
this be? How can the innerHTML property be different from the actual
contents ?

Please help me with this ...
 
B

Bergamot

allie said:
I have a problem with inconsistency in IE browser, looking at the
innerHTML property and the actual contents.

Why don't you go ask in a Microsoft newsgroup?
microsoft.public.<something IE-related>
 
C

CRON

i had the same problem a while back - i fixed it by using php
str_replace to just strip all P tags and replace em with <br/>
 
A

allie

CRON said:
i had the same problem a while back - i fixed it by using php
str_replace to just strip all P tags and replace em with <br/>

yes, that's what I also did. I am just wondering, is there something
else that you can put inside a <p> tag that is like an empty character,
so that it will be recognized as a line break, not showing anything ?

So not <p>&nbsp;</p> or <p> </p>, because this still shows a space
on the empty paragraph. But is there nothing else?

And bergamot: why is this microsoft related?
 
B

Bergamot

allie said:
And bergamot: why is this microsoft related?

Is your query not specific to *Microsoft* Internet Explorer, and a
discrepancy with innerHTML, which happens to be proprietary to MS as well?

It begs the question: Why is this *not* Microsoft related?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top