开发者

Making IE not to hang with unsupported Javascript?

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...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜