Hi ,
It seems as though i just needed to add the div to body like this.
document.body.appendChild(div);
thanks 4 the help.
I have one more problem currently i find the width and hieght of the screen using the offsetWidth and offsetHieght of the body element. In I.E the correct value is returned but in firefox i get the value of the element below it which is incorrect. Do you know the method to call so that in mozilla i can get the width and height of the screen.
Thank you
Reagrds,
Ryan
On 10/07/06, Java Mad <[EMAIL PROTECTED]> wrote:
work around or have a look at this : Have a look at the attachment too<body></body>
<script>
var div = document.createElement("DIV");
div.width= "1";
div.style.backgroundColor = "yellow";
div.style.width = "1";
div.style.visibility = "hidden";
div.innerHTML = "Test";
document.body.appendChild(div);
alert(div.offsetWidth);
div.style.visibility = "visible";
</script>
Ryan Meder <[EMAIL PROTECTED]> wrote:HiThanks JAVA Mad.clientWidth also returns a zero value.Here is a more detailed version of my code.this.layer = document.createElement("div");
this.layer.id = "wpDropMenuCtrl";
this.layer.className = this .menuClass;
// Create Content (Items)
var sHtml = "<ul id='wpDropMenuCtrlList'>" ;for (var i=0; i < menuItems.length; i++) {
var myArray = menuItems[i].split(SEP);
sHtml = sHtml + this.buildListItem(myArray[0], myArray[1]);
}
sHtml = sHtml + "</ul>";
this.layer.innerHTML = sHtml;
this.layer.style.visibility = "visible";
Before I set the the div to be visible. I need to know what the width of my div will be and set the "offsetTop" and "offsetLeft". The reson for this is if my div is to close to the right of the screen it must then display towords the left of the screen. Unfortunitly i dont know what the contnat of my menu is going to be until it is displayed so i cant set the width before hand as it could be of any width depending on the data that is recived from the server.Maby i should do this in another way to solve my problem any help?thank you
On 10/07/06, Java Mad <[EMAIL PROTECTED] > wrote:try...setting the noWrap property to true.ortry and use the clientWidth
Ryan Meder <[EMAIL PROTECTED]> wrote:
Hi,I would like to ask a _javascript_ question for my pop up menu. My menu that pops up is created dynamically using _javascript_ and the contents and links on the menu are created according to data from the db. The way it works is as the user clicks on an icon the data is requested from the server to populate the drop down menu using an Ajax request.The code is a "div" element like (this.layer = document.createElement("div");)I then add the contents of the menu the to object called "layer" and display the menu to the screen.What I require is to get the width or the offsetWidth off the Div object that I have dynamically created. At the moment when the method "offsetWidth" is called I get the value "0". Is there any way I can get this value before I display the element to the screen so that I can display it correctly.Any help would be helpful.Regards,Ryan
How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
--Regards,
Ryan Meder
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.
--
Regards,
Ryan Meder
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
For the ctjug home page see http://www.ctjug.org.za
-~----------~----~----~----~------~----~------~--~---
- [CTJUG Forum] Width of dynamically created div menu popup Ryan Meder
- [CTJUG Forum] Re: Width of dynamically created div menu ... Java Mad
- [CTJUG Forum] Re: Width of dynamically created div m... Ryan Meder
- [CTJUG Forum] Re: Width of dynamically created d... Java Mad
- [CTJUG Forum] Re: Width of dynamically creat... Java Mad
- [CTJUG Forum] Re: Width of dynamically creat... Ryan Meder
- [CTJUG Forum] Re: Width of dynamically ... Java Mad
- [CTJUG Forum] Re: Width of dynamica... Ryan Meder
- [CTJUG Forum] Width of dynamically created div menu popu... Paul Gilowey
- [CTJUG Forum] Width of dynamically created div menu popu... Paul Gilowey
