473,396 Members | 1,891 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,396 software developers and data experts.

Adding dynamic DIVs into an existing DIV

2
Hi all,
I am new to this forum and javascript. I am developing a progress bar in javascript. For that I planned to have series of small DIVs in a big DIV. I have written a below function.It is working in IE, but not in Firefox.

Expand|Select|Wrap|Line Numbers
  1. function createDiv(leftPx, topPx, widthPx, heightPx, divColor)
  2. {
  3.     dv = document.createElement('div');
  4.     dv.style.position="absolute";       
  5.     dv.style.pixelLeft=leftPx;
  6.     dv.style.pixelTop=topPx;
  7.     dv.style.pixelWidth=widthPx;
  8.     dv.style.pixelHeight=heightPx;
  9.     dv.style.backgroundColor=divColor;
  10.     dv.innerHTML='|';
  11.     parentDiv.appendChild(dv); // parentDiv = ID of bigger DIV defined in HTML 
  12. }
  13.  
I set a for loop to contineously change the leftPos and call the above function.

1. In IE, the progress bar is dislayed correctly. But in Firefox, individual DIVs are overwritten in the first place. The position of parent DIV is "relative".

2. I am not able to see individual DIVs, if dv.innerHTML='|'; line is commented. Is there any way to get the output without that?

I will appriciate if anyone helps me.

Thanks in advance.
Srini
Mar 31 '08 #1
3 1521
pronerd
392 Expert 256MB
1. In IE, the progress bar is dislayed correctly. But in Firefox, individual DIVs are overwritten in the first place. The position of parent DIV is "relative".
The pixelLeft, pixelTop, pixelWidth, and pixelHeight are not valid attributes in the Mozilla or the W3C DOM's
http://developer.mozilla.org/en/docs/DOM:CSS



2. I am not able to see individual DIVs, if dv.innerHTML='|'; line is commented. Is there any way to get the output without that?
Both Firefox and IE will at times not render empty layers or table cells. Insert " " instead of "|". It will keep the layer from being empty, and will be rendered as a blank space.
Mar 31 '08 #2
useenu
2
The pixelLeft, pixelTop, pixelWidth, and pixelHeight are not valid attributes in the Mozilla or the W3C DOM's
http://developer.mozilla.org/en/docs/DOM:CSS





Both Firefox and IE will at times not render empty layers or table cells. Insert " " instead of "|". It will keep the layer from being empty, and will be rendered as a blank space.
Thanks a lot. Now its working. But there is some height variation in displaying the DIVs with text(&nbsp or |). IE displays some of the content outside the main div.I am trying to resolve it. The link you have provided is very useful one.
Apr 1 '08 #3
pronerd
392 Expert 256MB
IE displays some of the content outside the main div.I am trying to resolve it.
That is because the position attribute is set to "absolute", and you have a fixed width value set. With the absolute value set the layer will only be as wide as it is defined regardless of the length of the content.
Apr 1 '08 #4

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

Similar topics

23
by: MattB | last post by:
Hello please help, I have a table cell with a div in it. The div has a width of 300px. but when it is rendered it puts extra space into the table cell. Here's the style <style>...
39
by: WindAndWaves | last post by:
Hi Gurus I have a page, which looks a bit like this: .... <body> <div ID=id1>................</DIV> <div ID=gsd>................</DIV> <div ID=ewd>................</DIV> <div...
1
by: Bob Bedford | last post by:
Hello, I've coded a tab pages somes years ago, with a search engine (with the help of an other programmer) allowing to search in many divs (any tab show/hide a div). Now, I've to change code...
5
by: Frances | last post by:
I need to replace iframes acc. to what option user chooses in a sel obj.. but figured have to load a blank iframe when pg loads so I can replace it.. (iframe gets put in a pre-existing div..) this...
12
by: meltedown | last post by:
I would like the floating divs to float and then the header to come after them , on the left. That's what I thought clearing the floats was for, but in this example, the header is to the right of...
3
by: Ankit Aneja | last post by:
I have a strange situation and I have no idea how to solve this. Its a Recruitment Search Page,in the Admin Page, for every button click event the Admin Person has to create a checkbox on the users...
1
by: snesbit | last post by:
I have a static ContextMenu already built and it works. I am trying to add a submenu (right arrow with a new menuitem list) dynamically when the popup is created. The new set of menuitems...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
9
by: pbd22 | last post by:
Hi. This is just a disaster management question. I am using XMLHTTP for the dynamic loading of content in a very crucial area of my web site. Same as an IFrame, but using XMLHTTP and a DIV. I...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.