Reply
another js problem. document.getElementById().width returning unassigned. why?
Old 07-21-2006, 07:59 PM another js problem. document.getElementById().width returning unassigned. why?
Novice Talker

Posts: 14
Name: Valentin
Here is my js function:

function setNewsPosition()
{
position=document.getElementById("image_1").width;//returns value
newsWidth= document.getElementById("news").width;//returns unassigned
alert(position);
var news= document.getElementById("news");
news.style.left= position + newsWidth + 'px';
}

Here is the css part that concerns the function:

div#news
{
float:left;
width:25%;
margin-left:-25%;
background:#0099cc;
}

I first thought it is because of the percentage value, but I've switched to px and it still returned unassigned. Does anyone have a suggestion why this might be and how it could be fixed?

Greetings,
Valentin
sanchopansa is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 07-21-2006, 10:03 PM Re: another js problem. document.getElementById().width returning unassigned. why?
funkdaddu's Avatar
Web Design Snob

Posts: 636
The JS can't read the CSS style - try using .offsetWidth instead.
funkdaddu is offline
Reply With Quote
View Public Profile Visit funkdaddu's homepage!
 
Reply     « Reply to another js problem. document.getElementById().width returning unassigned. why?
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12266 seconds with 12 queries