Search code examples
javascripthtmlcssinternet-explorer-10

Set IE specific css styles via javascript


I'm trying to set a CSS property, that is specific to IE, via javascript. Something like the following

document.body.style.-ms-content-zooming = "zoom";

or

document.body.style.-ms-scroll-snap-x = "whatever"

But the css property doesn't get set the way shown above (I tried the first line for sure). How could I accomplish the above task, or setting any css starting with a dash (-) for that matter, using javascript?


Solution

  • I do not have an Internet Explorer at hand but usually styles containing dashes are camelcased like:

    document.body.style.msContentZooming = "zoom";
    

    See this MSDN Blog post