Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Location
    Vermont, USA
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Smile converting CSS expression to javascript

    Hello,

    I am using a holy grail css website template which requires a CSS expression to work properly in IE7. The website renders fine in all major browsers but unfortunately does not validate. So, I moved the CSS expression (IE Dynamic Expression) to a separate JavaScript file. This kinda works but gives a syntax error. So, to reduce problems I am conditionally calling it using:

    Code:
    <!--[if IE 7]>
      <script type="text/javascript" src="./css/IE7fix.js"></script>
      <![endif]-->
    Now only IE7 is seeing it which is what I wanted. However, I understand CSS expressions are bad for performance as they are continually calculated every time the mouse moves, etc. So, I would like to convert the expression to pure JavaScript which would ideally resolve the syntax error and improve the performance.

    Unfortunately, I have not learned JavaScript yet, so was hoping someone could help explain what this code is actually doing. Maybe from there I can run with it and research the rest. This is the JavaScript file:

    Code:
    #container > #left { 	left: -240px; 	/* -LC width for others */ 
    margin-left:expression( document.all.center.offsetWidth * -1 + parseFloat
    (document.all.center.currentStyle.paddingLeft) + parseFloat
    (document.all.left.currentStyle.paddingLeft) + parseFloat
    (document.all.left.currentStyle.paddingRight) );  } /* Fix for IE7 */

    P.S.....the fix is discussed here: http://www.gerd-riesselmann.net/deve...ut-fix-for-ie7

    thanks....

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,273
    Thanks
    10
    Thanked 581 Times in 562 Posts
    Code:
    function els(em) {return document.getElementById(em).style;}
    
    els("left").marginLeft = ( document.all.center.offsetWidth * -1 + parseFloat
    (document.all.center.currentStyle.paddingLeft) + parseFloat
    (document.all.left.currentStyle.paddingLeft) + parseFloat
    (document.all.left.currentStyle.paddingRight) );
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • Users who have thanked rnd me for this post:

    codingkid (08-21-2008)

  • #3
    New to the CF scene
    Join Date
    Aug 2008
    Location
    Vermont, USA
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thank you for your efforts and surprisingly quick reply. I have implemented the code without any problems.

    Much obliged,

    ck


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •