function add(){ var userAgent = navigator.userAgent, rMsie = /(msie\s|trident.*rv:)([\w.]+)/, rFirefox = /(firefox)\/([\w.]+)/, rOpera = /(opera).+version\/([\w.]+)/, rChrome = /(chrome)\/([\w.]+)/, rSafari = /version\/([\w.]+).*(safari)/; var browser; var version; var ua = userAgent.toLowerCase(); var stu_name; function uaMatch(ua) { var match = rMsie.exec(ua); if (match != null) { alert("IE"); stu_name = $("#stu_name").text().split("\n"); alert(stu_name); } var match = rFirefox.exec(ua); if (match != null) { alert("rFirefox"); stu_name = $("#stu_name").val().split("\n"); alert(stu_name); } var match = rOpera.exec(ua); if (match != null) { alert("rOpera"); stu_name = $("#stu_name").val().split("\n"); alert(stu_name); } var match = rChrome.exec(ua); if (match != null) { alert("rChrome"); stu_name = $("#stu_name").val().split("\n"); alert(stu_name); } var match = rSafari.exec(ua); if (match != null) { alert("rSafari"); stu_name = $("#stu_name").val().split("\n"); alert(stu_name); } if (match != null) { alert("null"); stu_name = $("#stu_name").val().split("\n"); alert(stu_name); } } var browserMatch = uaMatch(userAgent.toLowerCase()); }