Forum Moderators: not2easy
And yes, I know that all that is possible using javascript and the 'style=' keyword. Let me dream :)
<DIV id="tab1" onClick="tab(1,true)" class="tab">
<IMG class="picL" SRC="images/tabl.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="">
<IMG class="picR" SRC="images/tabr.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="">
<DIV id="text1" class="text">Tab 1</DIV>
</DIV>
And in the stylesheet:
.tab {
position: absolute;
top: 0px;
width: 100%;
left: 0px;
height: 20px;
margin: 0px;
padding: 0px;
cursor: pointer;
}.text {
position: absolute;
border-color: #FFFFFF #FFFFFF #666666 #FFFFFF;
border-style: solid;
border-width: 1px 0px 1px 0px;
background-color: #CECECE;
font-size: 14px;
text-align: center;
top: 0px;
left: 20px;
right: 20px;
height: 20px;
margin: 0px;
padding: 0px;
}
.picL {
float: left;
margin: 0px;
padding: 0px;
}
.picR {
float: right;
margin: 0px;
padding: 0px;
}
Example:
<div style="width:expression(document.body.clientWidth/2)">
They're incredibly powerful and can be very useful if you get the opportunity to code for IE5+ only. If only they were a standard (or something similar).
left: 20px;
width: expression(document.body.offsetWidth - 40); I'm so lucky the project is for an IE5 only environment
So if you can't or don't want to go for "official" standards, write a documentation of how it's done and how it's supposed to work. That could even give you some extra credit. "See, it's browser specific, here's how it's done". To me, that sounds an awful lot better than "it's browser specific but that's no problem since there's only IE 5.x in this company".
Does that make sense?
width: expression(document.body.offsetWidth - 40); If the offsetWidth is less than 40 then we're trying to set the width to a negative value, and obviously it won't work. But instead of just ignoring it, IE gives a JavaScript error message telling the whole world that there is an "Invalid argument". Not pretty. :(
However, it's best to code around them by calling a function that ensures only *sensible* values are set, eg:
style="width:expression(getWidth();)"...
<script type="text/javascript">
function getWidth()
{
var returnWidth
if ((document.body.offsetWidth - 40) < 0)
{
returnWidth = 0;
}
else
{
returnWidth = document.body.offsetWidth - 40;
}return returnWidth
}</script>
Simple exception like this example can also be handled in-line with an immediate if, eg:
width:expression((document.body.offsetWidth-40) < 0 ? 0 : document.body.offsetWidth-40)