How to find the cell's width and position

A

Asra

Hello,

I have a table with width as 98% and all cell widths as 120. However,
these cell widths change with resolution changes. I have to find the
current cell width and its left position. Is there a browser
independent way to do that?

Best Regards,
Asra Baig
 
G

Grant Wagner

Asra said:
Hello,

I have a table with width as 98% and all cell widths as 120. However,
these cell widths change with resolution changes. I have to find the
current cell width and its left position. Is there a browser
independent way to do that?

Best Regards,
Asra Baig

When you write the table, use server-side code to divide the number of
columns by 100 and make each column that percentage wide:

<table ... width="98%">
<tr>
<%
var numberOfColumns = <some calculation>;
var columnWidth = Math.floor(100 / numberOfColumns);
for (var i = 0; i < numberOfColumns; ++i) {
Response.write(
'<th width="' + columnWidth + '%">' +
columnNames +
'</th>'
);
}
%>
</tr>

Now everything will scale nicely regardless of the browser width.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top