Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
600 views
in Technique[技术] by (71.8m points)

如何通过try catch 监测浏览器是否实现某个功能,如果实现将其调用否则进行提示。哪位大神教教小弟呀!

类似于QQ之类的应用的。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

为什么用try catch来实现呢?可以试试用if else来判断呀。
比如js实现原生ajax时

if(window.XMLHttpRequest){
      var xhr=new XMLHttpRequest();
  } else{
     //提示
  }

如果用try catch

try{
     var xhr=new XMLHttpRequest();
}catch(e) {
    //提示
}

如有错处,欢迎指正,谢谢。


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...