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 t开发者_运维问答his 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).
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){}
A try/catch block would be your best bet, I think...
精彩评论