Css expression not working in IE11

We have developed an application with an old version of IE7.

And the code contains "CSS expression", but that doesn't work in IE11.

Sample code:

div#GridViewContainer
        {
            position: relative !important;
            width: 1000px !important;
            overflow: auto !important;
        }
        _:-ms-fullscreen, :root .staticHeader
        {
            position: relative !important;
            top: expression(this.offsetParent.scrollTop);
            z-index: 99 !important;
        }
        _:-ms-fullscreen, :root .StaticColumn
        {
            z-index: 90 !important;
            border: 1px solid gray !important;
            position: relative !important;
           left: expression(document.getElementById("GridViewContainer").scrollLeft);
        }

      

How do I make it work in IE11 and an alternative way to do it?

How do I change my code?

+3


source to share


2 answers


OR

  • If you're feeling lazy or don't want to use JS, try setting document mode:

    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
    
          

    add it to the section <head>...</head>

    .

    Please note that this can damage properties that are not supported by IE7 that you may have used.


Why you should avoid using CSS expressions:



Starting with Internet Explorer 11, CSS expressions are no longer for web pages loaded in the Internet zone. CSS expressions are supported for pages loaded in other zones (such as the intranet zone) when pages are rendered in IE7 standards mode or in IE5 quirks mode.

- CSS expressions are no longer supported for the internet zone

Besides,

Unfortunately, the performance limitation imposed by CSS expressions is significant as the browser reevaluates each expression whenever an event is triggered, such as window resizing, mouse movement, etc. on the. The poor performance of CSS expressions is one of the reasons they are now deprecated in IE 8. If you have used CSS expressions in your pages, you should make every effort to remove them and use other techniques to achieve the same functionality.

- Page speed: avoid CSS expressions (deprecated)

Conditional comments should work somewhat, as suggested by Leo Caseirin in his answer, it will actually save you bandwidth on IE7 +.

+3


source


I suggest you split the file with your hacks and than, you can use conditional comments for IE like:

<link href="css/ie11-without-hacks.css" rel="stylesheet">
<!--[if lt IE 7]>
    <link href="css/ie7hacks.css" rel="stylesheet">
<![endif]-->

      



About conditional comments: https://msdn.microsoft.com/en-us/library/ms537512(v=vs.85).aspx

+1


source







All Articles