473,804 Members | 3,447 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IE not rendering class styles for dynamically created elements

32 New Member
Hello,

I was working on an Ajax-based page when I came across a little problem with IE7. If I create a page element in JavaScript and give it a class (to be styled of course) IE7 does not style the element properly once its added to the page.

Case in point, I've created a validated test page, http://dev.akeenlabs.com/test_addData.html , that demonstrates what I'm talking about.

Could someone please help me find a work around and/or tell me what I'm doing wrong in creating these objects.

Thanks.
Mar 28 '08 #1
3 2313
drhowarddrfine
7,435 Recognized Expert Expert
iirc, there are issues with dynamically set styles and when they are to be changed or set. This is a javascript problem so I'm transferring it there.
Mar 28 '08 #2
pronerd
392 Recognized Expert Contributor
You want to set the attribute 'className' not class.

So the line
Expand|Select|Wrap|Line Numbers
  1. newDiv.setAttribute('class', 'newDiv');
Should be

Expand|Select|Wrap|Line Numbers
  1. newDiv.className='newDiv';
Mar 28 '08 #3
poe
32 New Member
You want to set the attribute 'className' not class.

So the line
Expand|Select|Wrap|Line Numbers
  1. newDiv.setAttribute('class', 'newDiv');
Should be

Expand|Select|Wrap|Line Numbers
  1. newDiv.className='newDiv';
Thanks, that fixed it.
Mar 28 '08 #4

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

Similar topics

0
997
by: manju | last post by:
Hi, I use DHTML browser as my main application window and I create elements like <p>, <table>, <img> etc dynamically using MSHTML C++ interfaces like IHTMLDocument2::createElement IHTMLDOMNode::insertBefore and these elements appear in the browser after creation and insertion into the DOM. The problem is that if I create an element, say a <p> with some text, in a
1
3142
by: CS Wong | last post by:
Hi, I have a page form where form elements are created dynamically using Javascript instead of programatically at the code-behind level. I have problems accessing the dynamically-created elements and would like to seek a solution for this. I had looked through several articles for accessing programatically-created dynamic elements such as: 1)
10
2987
by: Jason Pettys | last post by:
I have an ASP.NET page that my client wants to e-mail. So in IE we choose File > Send > Page by E-mail, which opens up either Outlook or Outlook Express with the HTML page content as the message body. EXCEPT one nasty detail is that in the e-mail client, <input type="hidden"> elements are rendered as text boxes, which the __VIEWSTATE is one of, and so the viewstate is displayed in a textbox at the top of the e-mail. I've figured out...
2
1851
by: luke.crouch | last post by:
My server-side php script is generating an xml response with the following structure: <thread class='Columns'> <Id class='Column dataDetail'>12345</Id> <Command class='Column dataDetail'>SET</Command> .. .. .. </thread>
5
2344
by: paul.hester | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a problem in this scenario: <myprefix:mycontrol runat="server"> <%= SomeVariable %> </myprefix:mycontrol>
1
1233
by: JackBlack | last post by:
Hi, all! Using Win2k3 Server & IE 6 (all patches) on one box (web server), and XP/Pro & IE7 on another (workstation)... Project is a basic on-screen calendar with dynamically created table rows and columns (server side) and styles. Odd problem: if I render the table normally, some styles are ignored (such as the border-bottom attribute below): font-size:10px; color:Black;
3
1934
by: brian.turner | last post by:
This is sort of a design/javascript question. It involves CSS rendering in dynamic areas of a page using IE. E 6 & 7 HI There, We've created some example static html pages (using CSS) that look great in IE. We are now converting these into dynamic pages that use javascript to dynamically update certain areas of the page. After the conversion the dynamic areas of the page do not render the CSS styles (the styles are not displaying...
1
3131
by: rirby2 | last post by:
Hi everyone, I'm currently having a rendering problem in IE7 (haven't even tried the lower IEs yet), vs. what I see in FF2. The simplified site can be found at solerasd.com . (There are more image elements that belong in the list but I've only posted 2 since it replicates the problem and minimizes the code to read. In FF, you should see a logo with two images (currently not HREF's) of the same size below it, and a copyright statement below...
4
5636
Frinavale
by: Frinavale | last post by:
So a while ago I created a Tab Strip Control (before the AjaxToolkit had theirs otherwise I would have probably just used theirs). When I looked at the AjaxToolkit control to see how they got around this problem I discovered that they're using Animations. I don't want to bloat my control with the Ajaxtoolkit's Animation stuff though. I guess I should tell you what the problem is. I have a TabStrip custom control. It's a Table that has...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9166
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7631
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6861
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.