By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,747 Members | 1,349 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,747 IT Pros & Developers. It's quick & easy.

DOM created content in IE not respecting stylesheet

P: 69
Hi,

I've got a Javascript function to create some DOM content. The content is created fine in both IE and FireFox except that it FireFox it has styled the content according to the linked stylesheet, but in IE it has not.

Any ideas?

Regards,

Sean
Oct 24 '07 #1
Share this Question
Share on Google+
6 Replies


drhowarddrfine
Expert 5K+
P: 7,435
Without a link or the complete code, anything we say would be just a wild guess.
Oct 24 '07 #2

acoder
Expert Mod 15k+
P: 16,027
You posted this in the Articles section. Moved to the Forum section.
Oct 24 '07 #3

P: 69
It's a bit difficult to supply the code as it's being developed internally. The code works fine on Firefox but in IE its not using the stylesheet. If I copied everything that has been generated, the generated source of the document into another HTML page it renders fine. So no changes to the code result in a perfect page when it is created in advance. It's only when the same content is created using the DOM that it doesn't render properly.

Without a link or the complete code, anything we say would be just a wild guess.
Oct 24 '07 #4

acoder
Expert Mod 15k+
P: 16,027
Can you give some of the style rules that are not applied (or is it every rule)?
Oct 24 '07 #5

P: 69
Hi,

This is the class that is used by the text that is not being styled.

Expand|Select|Wrap|Line Numbers
  1. .black11pxplain {
  2.     font-family:Arial, Helvetica, sans-serif;
  3.     font-size:11px;
  4.     line-height:14px;
  5.     color:#000000;
  6.     text-align:left;
  7. }
  8.  
It's included from an external file:

Expand|Select|Wrap|Line Numbers
  1. <link href="includes/main_styles.css" rel="stylesheet" type="text/css" />
And it's used as follows:
Expand|Select|Wrap|Line Numbers
  1. <td height="25" valign="middle" class="black11pxplain">Sub Heading</td>
  2.  
What's frustrating is that the HTML page is a mixture of static and dynamic content. The static content is rendered fine, it's the dynamic content that's not rendered according to the stylesheet. I've tried linking the stylesheet at runtime and again the static content gets rendered according to the stylesheet. I thought maybe it was not reapplying the stylesheet to what had been created at runtime using the DOM.

I'm lost.

Can you give some of the style rules that are not applied (or is it every rule)?
Oct 24 '07 #6

P: 31
Are you setting classes using setAttribute?

If so you need to use setAttribute("classname", "name_of_class");
In internet explorer and setAttribute("class", "name_of_class"); for all the other web browsers
Oct 25 '07 #7

Post your reply

Sign in to post your reply or Sign up for a free account.