shivboy
05-18-2003, 05:38 PM
Hi,
I have been meaning to create this page with CSS properties having percentage values insead of values in pixels. Well its all fine till there. Now if i try to check for the width or height of a layer it displays nothing in the alert box. im posting the code along, kindly let me know whats wrong here.
<html>
<head>
<title></title>
<style>
.super {top: 0%; left: 0%; height: 100%; width: 100%; position: absolute; background-color: green;}
.d0 {top: 20%; left: 30%; height: 10%; width: 30%; position: absolute; background-color: red;}
.d1 {top: 10%; left: 1%; height: 10%; width: 10%; position: absolute; background-color: blue;}
.d2 {top: 10%; left: 89%; height: 10%; width: 10%; position: absolute; background-color: orange;}
</style>
<script language="JavaScript">
function growL()
{
var s = document.getElementById("oA").style;
var w = s.width;
alert(w);
}
</script>
</head>
<body onload="">
<div id="sD" class="super">
<div id="oA" class="d0"></div>
<div id="oB" class="d1"><a href="#" onClick="growL()">Click</a></div> <div id="oC" class="d2"></div>
</div>
</body>
</html>
I have been meaning to create this page with CSS properties having percentage values insead of values in pixels. Well its all fine till there. Now if i try to check for the width or height of a layer it displays nothing in the alert box. im posting the code along, kindly let me know whats wrong here.
<html>
<head>
<title></title>
<style>
.super {top: 0%; left: 0%; height: 100%; width: 100%; position: absolute; background-color: green;}
.d0 {top: 20%; left: 30%; height: 10%; width: 30%; position: absolute; background-color: red;}
.d1 {top: 10%; left: 1%; height: 10%; width: 10%; position: absolute; background-color: blue;}
.d2 {top: 10%; left: 89%; height: 10%; width: 10%; position: absolute; background-color: orange;}
</style>
<script language="JavaScript">
function growL()
{
var s = document.getElementById("oA").style;
var w = s.width;
alert(w);
}
</script>
</head>
<body onload="">
<div id="sD" class="super">
<div id="oA" class="d0"></div>
<div id="oB" class="d1"><a href="#" onClick="growL()">Click</a></div> <div id="oC" class="d2"></div>
</div>
</body>
</html>