Search code examples
cssif-statementinternet-explorer-6

<!--[if IE6]> block doesn't work


<!--[if IE6]>
        #refresh{
            position:absolute;
            left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||100));
            top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||50)));
        }
    <![endif]-->

This code block intend to solve the problem that ie6 doesn't recognise

position : fixed;

But it doesn't run unless I add something into the if block.

<!--[if IE6]>
        body{}//just like this
        #refresh{
            position:absolute;
            left:expression(eval(document.documentElement.scrollLeft+document.documentElement.clientWidth-this.offsetWidth)-(parseInt(this.currentStyle.marginLeft,10)||0)-(parseInt(this.currentStyle.marginRight,10)||100));
            top:expression(eval(document.documentElement.scrollTop+document.documentElement.clientHeight-this.offsetHeight-(parseInt(this.currentStyle.marginTop,10)||0)-(parseInt(this.currentStyle.marginBottom,10)||50)));
        }
    <![endif]-->

Could you tell me why did it happen?


Solution

  • You are missing the <style> tag:

    <!--[if IE6]>
        <style type="text/css">
            #refresh{
                position:absolute;
                /* ... */
            }
        </style>
    <![endif]-->