473,414 Members | 1,711 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

innerHTML and style attributes

I have an application where a user can create a newsletter with a
contenteditable div box and submit it to a database. The problem occurs
when the user tries to edit their newsletter. The edit page looks
exactly like the create page only their already created newsletter is
supposed to appear in the contenteditable div box. To do this I
retrieve the information from the database in the server side. Then I
have the following client side script.

window.onload=doInit
function doInit() {
var content = "<%=sContent%>";
div.innerHTML = content;
}

This seems to work in all cases except if the HTML to be displayed
contains any style attributes. For example, if any of the text has
background color then the HTML code will have the tag <font
style="bacground-color: #000000"> and this will cause nothing to appear
in the div box. Has anyone run into this problem or know how to fix it?

Nov 23 '05 #1
1 1766
brian4cards wrote:
I have an application where a user can create a newsletter with a
contenteditable div box and submit it to a database. The problem occurs
when the user tries to edit their newsletter. The edit page looks
exactly like the create page only their already created newsletter is
supposed to appear in the contenteditable div box. To do this I
retrieve the information from the database in the server side. Then I
have the following client side script.

window.onload=doInit
function doInit() {
var content = "<%=sContent%>";
div.innerHTML = content;
}

This seems to work in all cases except if the HTML to be displayed
contains any style attributes. For example, if any of the text has
background color then the HTML code will have the tag <font
style="bacground-color: #000000"> and this will cause nothing to appear
in the div box. Has anyone run into this problem or know how to fix it?


Have you tried changing the *background-color* property? It works for
me. :-)

I'd also suggest replacing the deprecated font element with a span.
--
Rob
Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andrew Poulos | last post by:
Given that I need to be able to add a TYPE attribute when I'm using createElement and it seems to fail in both IE and FF (but not MZ) is it 'safer' to use innerHTML instead? I can dynamically...
4
by: Anders Nielsen | last post by:
Hi :-) I'm currently working with innerHTML , but it is giving me some problems with " and '. Basically (there is also some ASP involved), my problem looks like this: I would like to,...
4
by: RobG | last post by:
I know you aren't supposed to use innerHTML to mess with table structure, but it seems you can't use it just after a table without damaging the containing element. I added a table to a div using...
3
by: ilia | last post by:
Hi All, I am a newbie in terms of Javascript, I found some code on the net to swap rows in a table using innerHTML, this works fine in Firefox but IE is complaining, after some googling around I...
5
by: gesres | last post by:
I have some column headings whose widths are set via styles: <TR> <TD style="visibility:hidden;width:0px">&nbsp;</TD> <TD style="visibility:hidden;width:0px">&nbsp;</TD> <TD...
3
by: e271828 | last post by:
I've got a way to get all of the source HTML for a given page by line and detect where certain attributes exist, and I would like to write the line of HTML code I've been working on into a new...
2
by: ars | last post by:
hi everyone i'm using some regular expression to paging, it work's fine in IE but not in Firefox i removed every thing to detect problem but i Can't , the only thing i got, is the innerHtml doent...
3
by: SJ | last post by:
Hi, So I am trying to save off my source HTML to an xml document in order to cache a large view within my ajax app. For those of you familiar with this, the innerHTML does not preserve the...
8
Toxinhead
by: Toxinhead | last post by:
Hey there guys I am having a little trouble with InnerHTML as i can't seem to figure out how to set the style of my div tag..... What im trying to do is that when i rollover pic1 it changes that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.