//首页搜索事件 function SiteSearch(send_url, divTgs) { var strwhere = ""; var str = $.trim($(divTgs).val()); if (str.length > 0) { strwhere += "?keyword=" + encodeURI($(divTgs).val()); } window.location.href = send_url + strwhere; return false; } /*检测浏览器方法 ------------------------------------------------*/ var pageurl = window.location.search; if (pageurl == '?m2w') { addCookie('m2wcookie', '1', 0); } if (getCookie('m2wcookie') != '1' && browserRedirect()) { if(location.href.indexOf(".aspx")!=-1||location.href.indexOf(".html")!=-1) { var href="http://"+ location.host +"/mobile"+ location.pathname + location.search; window.location.href = href; } else{ window.location.href = "http://www.chem.yuwei-crystal.com/mobile/index.aspx"; } } /*工具类方法 ------------------------------------------------*/ //检测是否移动设备来访 function browserRedirect() { var sUserAgent = navigator.userAgent.toLowerCase(); var bIsIpad = sUserAgent.match(/ipad/i) == "ipad"; var bIsIphoneOs = sUserAgent.match(/iphone os/i) == "iphone os"; var bIsMidp = sUserAgent.match(/midp/i) == "midp"; var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; var bIsUc = sUserAgent.match(/ucweb/i) == "ucweb"; var bIsAndroid = sUserAgent.match(/android/i) == "android"; var bIsCE = sUserAgent.match(/windows ce/i) == "windows ce"; var bIsWM = sUserAgent.match(/windows mobile/i) == "windows mobile"; if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { return true; } else { return false; } } //写Cookie function addCookie(objName, objValue, objHours) { var str = objName + "=" + escape(objValue); if (objHours > 0) {//为0时不设定过期时间,浏览器关闭时cookie自动消失 var date = new Date(); var ms = objHours * 3600 * 1000; date.setTime(date.getTime() + ms); str += "; expires=" + date.toGMTString(); } document.cookie = str; } //读Cookie function getCookie(objName) {//获取指定名称的cookie的值 var arrStr = document.cookie.split("; "); for (var i = 0; i < arrStr.length; i++) { var temp = arrStr[i].split("="); if (temp[0] == objName) return unescape(temp[1]); } return ""; } function valideEmail(value) { //对电子邮件的验证 var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; if (!myreg.test(value)) { alert('请输入有效的E_mail!'); return false; } return true; } function validatemobile(mobile) { if (mobile.length != 11) { alert('请输入有效的手机号码,需是11位!'); return false; } var myreg =/^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/; if (!myreg.test(mobile)) { alert('请输入有效的手机号码!'); return false; } return true; } function yySiteSearch(send_url, divKeyword) { var strwhere = ""; var str = $.trim($(divKeyword).val()); if (str.length > 0) { strwhere += "&keyword=" + encodeURI($(divKeyword).val()); } window.location.href = send_url + strwhere; return false; } //根据时间周期查询 function DateSearch(send_url, date, divKeyword) { var strwhere = ""; var theDate = $.trim(date); if (theDate.length > 0) { strwhere += "&date=" + encodeURI(theDate); } var str = $.trim($(divKeyword).val()); if (str.length > 0) { strwhere += "&keyword=" + encodeURI($(divKeyword).val()); } window.location.href = send_url + strwhere; return false; } //根据关键字和时间周期查询 function DateKeywordSearch(send_url, keyword, date) { var strwhere = ""; if (keyword.length > 0) { strwhere += "&keyword=" + keyword; } if (date.length > 0) { strwhere += "&date=" + date; } window.location.href = send_url + strwhere; }