htmlArea

A directory of browser-based WYSIWYG editors

  MAIN
INDEX
SEARCH
POSTS
WHO'S
ONLINE
LOG
IN

Home: WYSIWYG Forums: WYSIWYG Editor Discussion:
convert CSS Style into HTML language


 


Quicksand
New User

Mar 11, 2005, 9:11 AM

Post #1 of 7 (113656 views)
Shortcut
convert CSS Style into HTML language Can't Post

Hi folks,

I try to use htmlArea 3 to write emails. But the email accounts like hotmail, or the email Reader like Outlook can't show the email correctly. So I'm looking for a class or code written in PHP which can convert the CSS Style code in HTML code.

Output htmlArea 3:
<td style="text-align: left; vertical-align: top; width: 50%; background-color: rgb(51, 255, 0); background-image: none;">hello</td>

Convert into:
<td border="0" align="left" valign="top" width=50% bgcolor=#33ff00>hello</td>

Can anybody help me?

thx


nikotto
User

Mar 11, 2005, 10:32 AM

Post #2 of 7 (113640 views)
Shortcut
Re: [Quicksand] convert CSS Style into HTML language [In reply to] Can't Post

very difficult if not impossible!

imho writing emails with htmlarea could be nice - but designing html-mails with tables that work in all those stupid email-clients and webmails is nearly impossible!

once i did allready, but it ended up in doing everything in the html-code-view.
now we changed the newsletter tool to have the general (table)-design static and only the content is entered through htmlarea.


Jorgen Horstink
Novice

Mar 13, 2005, 9:35 AM

Post #3 of 7 (113586 views)
Shortcut
Re: [nikotto] convert CSS Style into HTML language [In reply to] Can't Post


In Reply To
very difficult if not impossible!


Not impossible at all. Insert a hidden iframe. Write the content of htmlArea to the frame so you can access the DOM tree. Walk the DOM tree, search for table elements. Retrieve the style attributes. Set the attributes and remove the style attributes.
After that: get the content of the frame.

So, quite easy. It would be better to hack this into htmlArea.


Quicksand
New User

Mar 13, 2005, 10:00 AM

Post #4 of 7 (113581 views)
Shortcut
Re: [Jorgen Horstink] convert CSS Style into HTML language [In reply to] Can't Post

Yes, that were my thoughts. But how do I make that?

Now I explode the whole HtmlArea String by ">", then I am searching for the keyword "<table" and then . . .?!?!? How do I extract the CSS with the attributes into a new string (only HTML), that will replace the old one?


Jorgen Horstink
Novice

Mar 13, 2005, 10:39 AM

Post #5 of 7 (113576 views)
Shortcut
Re: [Quicksand] convert CSS Style into HTML language [In reply to] Can't Post

I made a simple example for you. As far as I know valign and bgcolor are deprecated and forbidden on td tag.


Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" 
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>NextAvenue | NextAvenue - Welkom</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<script type="text/javascript">

string = "<table><tr><td style=\"text-align: left; vertical-align: top; width: 50%; background-color: rgb(51, 255, 0); background-image: none;\">hello</td></tr></table>";

window.onload = function (e) {
var frame = document.createElement('iframe');
frame.id = 'myFrame';
document.body.appendChild(frame);
frame = document.getElementById('myFrame');
var doc = frame.contentWindow;
doc.onload = function (e) {
doc.document.write(string);
var tds = doc.document.getElementsByTagName('td'), td, i = tds.length;
while (i--) {
td = tds;
td.align = td.style.textAlign; td.style.textAlign = "";
td.width = td.style.width; td.style.width = "";
}
alert(doc.document.body.innerHTML);
}
}
</script>
</head>
<body>

</body>
</html>



Quicksand
New User

Mar 15, 2005, 10:43 AM

Post #6 of 7 (113529 views)
Shortcut
Re: [Jorgen Horstink] convert CSS Style into HTML language [In reply to] Can't Post

That is simple? Pirate

I'm not good in Javascript. I'm scheiße in Javascript.

The only way for me is PHP.


dewi
New User

Mar 30, 2005, 6:22 AM

Post #7 of 7 (113415 views)
Shortcut
Re: [Quicksand] convert CSS Style into HTML language [In reply to] Can't Post

hello

i think you have to make email in html format not in plain text

i think if you still use the html code for sending email and it is plain text, you will still get the code html (not convert it very well). So my suggestion, you have to create email in html format

 
 
 


Search for (options)