473,799 Members | 3,422 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding dynamic DIVs into an existing DIV

2 New Member
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 1535
pronerd
392 Recognized Expert Contributor
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.mozil la.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 New Member
The pixelLeft, pixelTop, pixelWidth, and pixelHeight are not valid attributes in the Mozilla or the W3C DOM's
http://developer.mozil la.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 Recognized Expert Contributor
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
18646
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> #treecontainer {
39
3656
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 ID=fac>................</DIV>
1
1850
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 as new tabs are added. I've a frame where I load the tabs and fill div with queries, and an other frame where I have the search form. I'm looking for a way to have dynamic creation of the code, depending on the loaded divs or tabs.
5
2234
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 is approach.. I'm having some problems and would appreciate some help.. thank you very much... var selItem; var ifrCurr; var div = document.getElementById("divPricing"); // this var not being read inside functions..
12
2821
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 the floating divs, nothing is cleared. What am I doing wrong ? Here is the url:http://www.reenie.org/test/test5.php Here is the code: <html> <head>
3
2346
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 page. So whenever the Admin person comes to know about the new category in the market he will be adding as different Sub-Categories for example ABAP, BDC etc..etc.. on every click event as Checkboxes. And these controls(checkboxes) should remain...
1
2060
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 requires some DB queries to be done and then the menuitems to be added to the Menuitems collection of an existing menuitem This operation is sensitive to the record that the user has right clicked, so this dynamic sublist of actions can be different...
9
3631
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 to create the dynamic controls in the OnInit stage of the lifecycle. Since data from static controls is not yet available in the OnInit stage I can't know what dynamic control I have to create.
9
2986
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 got the core of the javascript from here: http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm I noticed in the demo that sometimes the content takes a long
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10490
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
10259
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
10238
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,...
1
7570
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
6809
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();...
0
5467
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4145
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
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.