Here's a slightly enchanced script that I posted not so long ago (look thread216-221307). It shows you the top/left and wifth/height of any page element:
<script>
function elemHeight(elemName) {
if (document.layers)
h = eval("document.layers[" + elemName + "].document.height"
else if (document.getElementById)
h = eval("document.getElementById('" + elemName + "').offsetHeight"
return(h);
}
function elemWidth(elemName) {
if (document.layers)
w = eval("document.layers[" + elemName + "].document.width"
else if (document.getElementById)
w = eval("document.getElementById('" + elemName + "').offsetWidth"
return(w);
}
function elemTop(elemName) {
if (document.layers)
t = eval("document.layers[" + elemName + "].document.pageY"
else if (document.getElementById)
t = eval("document.getElementById('" + elemName + "').offsetTop"
return(t);
}
function elemLeft(elemName) {
if (document.layers)
l = eval("document.layers[" + elemName + "].document.pageX"
else if (document.getElementById)
l = eval("document.getElementById('" + elemName + "').offsetLeft"
return(l);
}
function elemProps(elemName) {
w = "width= " + elemWidth(elemName);
h = "height= " + elemHeight(elemName);
t = "top= " + elemTop(elemName);
l = "left= " + elemLeft(elemName);
dims = "element name: " + elemName + "\n\n" + w + "; " + h + "\n" + t + "; " + l;
return(dims)
}
</script>
To make it compatible with IE4 change this:
[tt]if (document.getElementById)[/tt]
to this:
[tt]if ( (document.getElementById) ||
(document.all) ) [/tt]
To see the properties of any block element or link add this:
<a href="#" id="
test" name="test" onmouseover="alert(
elemProps('test'))">
or
<div id="
first" style="border: solid 1px black; width:200px" onclick="alert(
elemProps('first'))">b l o c k <br> c o n t e n t</div>
Tested in Opera 6, IE5 and Netscape 6.2
It may be also useful for others. You are free use it as it is, or adjust for your specific needs.
good luck