Click to See Complete Forum and Search --> : Sick and tied of <P>'s appearing on my WYSIWIG editor


newt3
02-10-2005, 03:36 PM
Hi there all,

I wonder if you guys can help me?

I've written a online WEB editor (WYSIWIG editor using Javascript), the editor is in an ASP page. When I submit the data and go back in to view the data it keeps appending <P>'s. Is there away so when I save the HTML is gets rid of the <P>'s.

And when I do everything on the edito, and switch to the HTML view it places <P> everywhere, is there a way to place <BR> instead?

Hope this makes sence? Many thanks
Newt3

buntine
02-10-2005, 09:31 PM
Use the Replace function.

yourContent = Replace(yourContent, "<p>", "<br />")

yourContent refers to a variable that contains the contents of the HTML editor pane.

Regards.

Pittimann
02-11-2005, 09:14 AM
Hi!

It seems you are using IE's isContentEditable stuff. If so: it inserts opening and closing p-tags. Using the Replace function would of course be a way to get rid of them and insert <br>'s instead, but I guess that the only thing disturbing you is the 'gap' between the lines. To get rid of that without avoiding p-tags, just use a little css. Here is a little example:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Example</title>
<style type="text/css">
<!--
p.br{
margin:0;
}
-->
</style>
</head>
<body>
<div>
<p class="br">I am inside a "special" p-tag</p>
<p class="br">I am inside a "special" p-tag</p>
I am followd by a br-tag<br>
I am followd by a br-tag<br>
<p class="br">I am inside a "special" p-tag</p>
I am followd by a br-tag<br>
<p class="br">I am inside a "special" p-tag</p>
<p>I am inside a "normal" p-tag</p>
<p>I am inside a "normal" p-tag</p>
<p>I am inside a "normal" p-tag</p>
<p>I am inside a "normal" p-tag</p>
</body>
</html>Cheers - Pit