Pārlūkot izejas kodu

判断浏览器类型

wyq 4 gadi atpakaļ
vecāks
revīzija
b5ca4770ad
1 mainītis faili ar 19 papildinājumiem un 5 dzēšanām
  1. 19 5
      src/js/staticInfo.js

+ 19 - 5
src/js/staticInfo.js

@@ -19,7 +19,7 @@ const {
 } = require('./promise.js');
 const $ = require("jquery");
 require("./jquery-migrate");
-require("./PIE");
+
 const jqprint = require("../js/jquery.PrintArea")
 let printing = require('./../images/printing.png');
 let printing2 = require('./../images/printing2.png');
@@ -27,6 +27,20 @@ let recommend = require('./../images/recommend.png');
 let hel = require('./../images/icon-hel.png');
 
 let showName, noticeName, clinicalPathwayName, isclick
+
+function myBrowser() {
+  var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
+  var isOpera = userAgent.indexOf("Opera") > -1;
+  if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
+    return "IE";
+  }; //判断是否IE浏览器
+}
+//以下是调用上面的函数
+var mb = myBrowser();
+if ("IE" == mb) {
+  require("./PIE");
+}
+
 function getInfomation() {
   var param = {
     "type": getUrlArgObject('type'),
@@ -356,8 +370,8 @@ function getResult(pushInfo, textType) {
           multarr.push($(this).attr("data_obj"))
         }
       });
-      
-      if (multarr.join(";")){
+
+      if (multarr.join(";")) {
         arr.push(multname + multarr.join(";"))
       }
       tmp = arr.join(";");
@@ -367,7 +381,7 @@ function getResult(pushInfo, textType) {
             result = pushInfo[i].result + '(' + num + '分' + ')'
             proposal = pushInfo[i].pushInfo
             break
-          } else if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && tmp){
+          } else if (pushInfo[i].content.max >= num && num >= pushInfo[i].content.min && tmp) {
             result = pushInfo[i].result + '(' + num + '分' + ')' + ';' + tmp
             proposal = pushInfo[i].pushInfo
             break
@@ -378,7 +392,7 @@ function getResult(pushInfo, textType) {
       } else {
         result = tmp
       }
-      
+
       if (result == undefined) {
         if ($.inArray(13, textType) > 0) {
           $(".score").html('总分:' + num + '分');