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

about getting the size of an element

hi, i was wondering how to get the size of a text element in pixels.

another question:
why in mozilla this doesn´t work (it does in Opera 7 and IE6)
element.style.left = 50;
and how can i solve the problem
Thanks
Jul 23 '05 #1
2 1188
On Sun, 31 Oct 2004 11:26:53 +0100, Ricardo Garcia <th******@wanadoo.es>
wrote:
hi, i was wondering how to get the size of a text element in pixels.
What's a text element?
another question:
why in mozilla this doesn´t work (it does in Opera 7 and IE6)
element.style.left = 50;
and how can i solve the problem


Probably because it's invalid. Any length value, other than zero (0),
requires a unit. Change it to

element.style.left = '50px';

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
Jul 23 '05 #2


Ricardo Garcia wrote:
i was wondering how to get the size of a text element in pixels.
Get a reference to the element (e.g.
var element = document.getElementById('elementId');
) and then read
element.offsetWidth
element.offsetHeight

why in mozilla this doesn´t work (it does in Opera 7 and IE6)
element.style.left = 50;


Make sure element is a reference to an element object and then make sure
you use syntactically correct CSS e.g.
element.style.left = '50px';

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

27
by: skeeterbug | last post by:
please see http://www.geocities.com/operationsengineer1/test.htm for an idea of how i want my logo header div to be layed out. when i went to resize "Test" to 2em (from 1em), this is what...
5
by: John | last post by:
Hi all, Can a linked list be a member of a structure? If so, when I add or remove an element from the linked list, the size of the structure will change. Will it cause any problem? Thanks a...
3
by: Jack | last post by:
On the 1st of January 1998, Bjarne Stroustrup gave an interview to the IEEE's 'Computer' magazine. Naturally, the editors thought he would be giving a retrospective view of seven years of...
21
by: Michael Bierman | last post by:
Please forgive the simplicy of this question. I have the following code which attempts to determine the color of some text and set other text to match that color. It works fine in Firefox, but does...
7
by: Rano | last post by:
/* Hello, I've got some troubles with a stupid program... In fact, I just start with the C language and sometime I don't understand how I really have to use malloc. I've readden the FAQ...
1
by: robing | last post by:
I am having trouble getting data from a text input field element. the element is called amount_$counter with $counter being the row of the table. when i have made an input to the text field and...
4
by: clqrq | last post by:
i want to do the following.... 1) fill a struct (lets call it Data) 2) push it to a vector of Data 3) get a pointer to pushed vector-element. std::vector<DatavData; (lets assume we now...
4
by: Andreas Borutta | last post by:
Hi, what is the task with which I could not cope? There is a link with an inline-element (strong e.g.) inside. It has a higher font-size than the content of its parent. For the hover effect...
160
by: raphfrk | last post by:
Is this valid? int a; void *b; b = (void *)a; // b points to a b += 5*sizeof(*a); // b points to a a = 100;
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.