Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



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

Posts: 14
Name: Valentin
Trades: 0
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
 
 
Register now for full access!
Old 07-21-2006, 11:03 PM Re: another js problem. document.getElementById().width returning unassigned. why?
funkdaddu's Avatar
Web Design Snob

Posts: 635
Trades: 0
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 Search this Thread
Search this Thread:

Advanced Search

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

BB 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.10236 seconds with 12 queries