Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ContentEditable DIV

Status
Not open for further replies.

rico14d

Programmer
Apr 8, 2002
135
GB
Hi all,

Im using a ContentEditable Div which is working fine but when I press return it jumps a line. Ive put an example below. After each line i press 'Return' once but i dont want it jump a line.

-----------------------------------------------------
Title

More Text

Hi
-----------------------------------------------------
The HTML this generates is..
-----------------------------------------------------
<P>Title</P>
<P>More Text</P>
<P>Hi</P>
-----------------------------------------------------

I can get it to work correctly if i cut and paste the text i want in there and it will put a <BR> in the correct place.

Does anyone know how i can stop this from happening?

Thanks,
Rich.
 
I did find the 'shift and enter' by accident using the MSDN example of contenteditable div.

Im not the one who is going to be using it though so ill have to train all my users to do so.

Thanks for your time Erik.

Rich.

 
Hey guys, I have the same problem...

here is a little work-around. I cannot get it to stop putting the <p> tags (like, who uses those anyway)

I even tried doing a RegExp replace of
Code:
<p>
tags with &quot;&quot; and
Code:
</P>
with
Code:
<br>
everytime someone hit enter... the control started adding &nbsp; in there to make it do bad things.

SO I added this little snippet to the top of the page:
Code:
<style>
p{
margin-top: 0px; 
margin-bottom: 0px;
} 
</style>


I put it on my controlling page, but you could probably insert the HTML at the top of the editable are as well. I didn't try that. So now there are <p> tags but they don't make a double space. So when you submit the code you can replace the tags you want without the control messing with it.

I hope it helps



Travis Hawkins
BeachBum Software
travis@cfm2asp.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top