views:

122

answers:

2

Hi,

I have a problem with IE. All other browsers work fine, but in IE the following example will make Javascript to stop entirely:

 elem = document.getElementById('asd');
 elem.style.background = '-moz-linear-gradient(top, rgba(138, 197, 229,0.85), rgba(92, 130, 153, 0.85))';

IE does not support gradients, I know, but why does it stop Javascript execution after the background line? All other browsers will continue normally and issue an empty background. Is there a way I can force IE to not go nuts?

The reason why I do this is because I want to test what the browser is capable of producing (e.g. if the background is empty, then I know it does not support moz gradient backgrounds).

+3  A: 

Try

try
{
elem = document.getElementById('asd');
 elem.style.background = '-moz-linear-gradient(top, rgba(138, 197, 229,0.85), rgba(92, 130, 153, 0.85))';
}
catch(err){}
ArsenMkrt
A: 

A try/catch block would be your best bet, I think...

James Aaron