Question

It is well known that ie8 doesn't support cmyk jpg images, it just doesn't render them at all :-(

here is one post about it http://www.plaveb.com/blog/cmyk-images-not-displayed-in-internet-explorer, there are countless others.

My question: Is there a a way to feature detect from javascript, similar to how modernizr works, to check if a browser supports cmyk jpg images?

I can put a hack in my javascript to change behaviour for ie8 to use a rgb jpg but I would like the hack to be a little more robust.

Thanks,

Was it helpful?

Solution

Something like this: (with jQuery of course their are HTML directives)

if ($.browser.msie  && parseInt($.browser.version, 10) <= 8) {
  alert('IE8 or below'); 
} else {
  alert('Non IE8');
}

and HTML ->

<!--[if IE 8]>
<script type="text/javascript">
    ie = 8;
</script>
<![endif]-->

Ok here is some Javascript, this works with RGBA, so it should with CMYK, you could test:

<html>
<head>
    <script>
    var IS_CMYK_SUPPORTED = (function(){
        var value = 'cmyk(1%,1%,1%,0.5%)',
        el = document.createElement('p'),
        result = false;
        try {
            el.style.color = value;
            result = /^cmyk/.test(el.style.color);
        } catch(e) { }
        el = null;
        return result;
    })();
    </script>
</head>
<body onLoad='alert("IS CMYK Supported:" + IS_CMYK_SUPPORTED)'>
</body>
</html>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top