// JavaScript Document /************************ 获取页面对象 ************************/ //根据id获取页面对象 function $(objID) { return document.getElementById(objID); } //根据name获取页面对象数组 function $Name(objsName) { return document.getElementsByName(objsName); } //根据tagname获取页面对象数组 function $TagName(objsTagName) { return document.getElementsByTagName(objsTagName); } //获取下拉控件select的当前选定项的值 function $dropGet(obj) { return obj.options[obj.selectedIndex].value; } //按值设置下拉控件select的当前选定项 function $dropSetByValue(dropobj,value) { var list = dropobj.options; for(var i=0;i 57)&&key != 46) { event.keyCode = 0; } else { if(key == 46) { event.keyCode = 0; } } } //限制只允许输入0~9及小数点 function KeyPressPoint(objTR) { var txtval=objTR.value; var key = event.keyCode; if((key < 48||key > 57)&&key != 46) { event.keyCode = 0; } else { if(key == 46) { if((objTR.value.length == 0) || (objTR.value.indexOf('.') >= 1)) { event.keyCode = 0; } } } } //限制只能输入数字和横线(-) function KeyPressLine(objTR) { var txtval=objTR.value; var key = event.keyCode; if((key < 48||key > 57)&&(key != 45)) { event.keyCode = 0; } } //限制不允许输入'和" function KeyPressYin(objTR) { var key = event.keyCode; if(key == 34||key == 39) { event.keyCode = 0; } } //限制不允许输入任何英文符号 function KeyPressNonSymbol(obj) { var key = event.keyCode; if((key>=33&&key<=47)||(key>=58&&key<=64)||(key>=91&&key<=96)||(key>=123&&key<=126)) { event.keyCode = 0; } } /********************************************** 页面跳转 **********************************************/ //跳到本页并且去除url参数 function RefreshMe() { // alert(location.pathname); location.href(location.pathname); } //跳转到本页,不去除参数 function LocationToMe() { location.href=location.href; } //跳转到本页,并删除指定的参数 //参数:param:应为匹配指定参数的js正则表达式字符串 function RefreshMeDelParam(param) { var url = location.href; var reg = new RegExp(param,"ig"); var x = url.replace(reg,""); LocationTo(x); } //跳到指定页 function LocationTo(url) { location.replace ( url); } //顶部窗口跳转 function TopLocationTo(url) { top.location.href(url); } //跳转到本页,并添加参数 function LocationToMeParam(param) { location.href(SetUrlAddParam(location.href,param)); } //提交本页 function SubmitToMeParam(url) { document.forms[0].action = url; document.forms[0].submit(); } //打开窗口的js类,默认打开空页面 function NewWindow() { this.Url = "about:blank"; this.Name = "_blank"; this.Height = Math.round(window.screen.height / 2); this.Width = Math.round(window.screen.width / 2); this.ToolBar = "yes"; this.MenuBar = "yes"; this.ScrollBars = "yes"; this.Location = "yes"; this.Status = "yes"; this.Resizable = "yes"; this.Left = Math.round(((window.screen.availWidth-this.Width)/2)/2); this.Top = Math.round(((window.screen.availHeight-this.Height)/2)/2); } NewWindow.prototype.Open = function() { window.open(this.Url,this.Name,'height='+this.Height+',width='+this.Width+',toolbar=' + this.ToolBar + ',menubar=' + this.MenuBar + ',scrollbars=' + this.ScrollBars + ',resizable=' + this.Resizable + ',location=' + this.Location + ',status=' + this.Status + ',left='+ this.Left +',top='+ this.Top +''); } //打开一个没有任何限制的窗口 function OpenUrl(url) { var win = new NewWindow(); win.Url = url; win.Open(); } //打开一个所有操作工具条都没有的窗口 function OpenUrlNonAll(url,width,height) { if(url == null || url == "") url = "/"; if(width == null || width == 0) width = Math.round(window.screen.width / 2); if(height == null || height == 0) height = Math.round(window.screen.height / 2); var win = new NewWindow(); win.Url = url; win.Height=height; win.Width = width; win.ToolBar="no"; win.MenuBar = "no"; win.ScrollBars = "auto"; win.Location = "no"; win.Status = "no"; win.Resizable = "yes"; win.Left = Math.round((window.screen.availWidth-win.Width)/2); win.Top = Math.round((window.screen.availHeight-win.Height)/2); win.Open(); } /*********************************************** 搜索动作 ***********************************************/ //设置文本框点击隐藏文字 var CONST_SEARCH_TEXT = "Enter keywords"; function SetTextBoxTextHidden(obj) { if(obj.value.Trim() == CONST_SEARCH_TEXT) { obj.value = ""; } obj.onfocus = function() { if(this.value.Trim() == CONST_SEARCH_TEXT) { this.value = ""; } }; obj.onblur = function() { if(this.value.Trim() == "") { this.value = CONST_SEARCH_TEXT; } }; } //热门搜索动作 function HotKeyClick(keyword,key) { $("txtSearchKeywords").value = keyword; //$("txtsearch_cid").value = key; CheckSearchBarInput('search'); $("txtSearchKeywords").form.submit(); } //搜索表单验证 function CheckSearchBarInput(formid) { if(($(formid).txtSearchKeywords.value.Trim() == "") || ($(formid).txtSearchKeywords.value.Trim() == CONST_SEARCH_TEXT)) { alert("Please enter your search keywords"); return false; } // key_cid=$(formid).txtsearch_cid.value.Trim(); // if(key_cid == "" ) // { // alert("请选择搜索类别"); // return false; // } $(formid).action="Products.html"; return true; } /****************************************** AXJX ******************************************/ var cncity_xmlHttp,ChangeCity; function cncity_createXMLHttp(){ if(window.ActiveXObject){ return new ActiveXObject("Microsoft.XMLHTTP"); } else if(window.XMLHttpRequest){ return new XMLHttpRequest(); } } function go_xmlhttp(url,evcity){ cncity_xmlHttp=cncity_createXMLHttp(); cncity_xmlHttp.onreadystatechange = evcity; cncity_xmlHttp.open("get",url,true); cncity_xmlHttp.send(null); } /****************************************** 注册 ******************************************/ function checkUsername(str){ var username=str.value; var ptn=/[0-9,a-z,A-Z,_]{3,16}/; if(username==""){ $g("spUsernameMsg","× Username is empty!"); return false; } if(username.match(ptn)==null){ $g("spUsernameMsg","× Username is Mistake!"); $("txtUsername").focus(); return false; } url="check.html?type=checkusername&username=" + escape(username) + "&x=" + Math.random(); if(go_xmlhttp(url,goUsername) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goUsername(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="1"){ $g("spUsernameMsg","√"); return true; }else if(root=="0"){ $g("spUsernameMsg","× "+$("txtUsername").value+" already exists!"); return false; }else{ $g("spUsernameMsg","× 未知错误!"); return false; } return false; } } return false; } function checkEmail(str){ var Email=str.value; var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; if(Email==""){ $g("spEmailMsg","× Email is empty!"); return false; } if(Email.match(reg)==null){ $g("spEmailMsg","× Email is Mistake!"); $("txtEmail").focus(); return false; } url="check.html?type=checkemail&email=" + escape(Email) + "&x=" + Math.random(); if(go_xmlhttp(url,goEmail) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goEmail(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="1"){ $g("spEmailMsg","√"); return true; }else if(root=="0"){ $g("spEmailMsg","× "+$("txtEmail").value+" already exists!"); return false; }else{ $g("spEmailMsg","× 未知错误!"); return false; } return false; } } return false; } function checkCode(str){ var Code=str.value; if(Code==""){ $g("msgCode","× Code is empty!"); return false; } url="check.html?type=checkcode&code=" + escape(Code) + "&x=" + Math.random(); if(go_xmlhttp(url,goCode) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goCode(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="1"){ $g("msgCode","√"); return true; }else if(root=="0"){ $g("msgCode","×"); return false; }else{ $g("msgCode","× 未知错误!"); return false; } return false; } } return false; } function checkPin(str){ var Pin=str.value; var reg=/^[a-z,A-Z,0-9]{6,16}/; if(Pin==""){ $g("msgPin","× password is empty!"); return false; } if(Pin.match(reg)==null){ $g("msgPin","× password is Mistake!"); $("txtPin").focus(); return false; }else{ $g("msgPin","√"); } return true; } function checkConfirmPin(str){ var Pin=str.value var reg=/^[a-z,A-Z,0-9]{6,16}/; if($("txtPin").value!=Pin) { $g("msgConfirmPin","× Enter the password twice inconsistent!"); return false; }else if($("txtPin").value!=""){ $g("msgConfirmPin","√"); } return true; } function ddlSecQus_Changed(str){ if(str.value==""){ $("txtSecQus").style.display=""; }else{ $("txtSecQus").style.display="none"; $("txtSecQus").value=str.value; } return true; } function checkD(src){ var val=src.value; var ptn=/^\d*$/; if(val.length>0&&!ptn.test(val)){ $g("msgAge","× Malformed"); return false; }else if(val.length>0){ $g("msgAge","√"); } return true; } function donly(e){ var key = window.event ? event.keyCode : e.which; if(key<27 || key >128) return true; else if(key >= 48 && key <= 57) return true; else return false; } function $g(str,html){ $(str).style.display=""; $(str).innerHTML=html; } function signUp(str){ var b1=checkUsername($("txtUsername")); var b2=checkEmail($("txtEmail")); var b3=checkPin($("txtPin")); var b4=checkConfirmPin($("txtConfirmPin")); var b5=checkD($("txtAge"),'msgAge'); var b6=checkCode($("txtCode")); if(b1&&b2&&b3&&b4&&b5&&b6){ $("register").action="?action=register"; return true; }else{ return false; } } /****************************************** 验证和提交评论 ******************************************/ function SubmitProductComment() { if($("txttitle").value.Trim() == "") { alert("Please enter title。"); return false; } if($("txtContent").value.Trim() == "") { alert("Please enter content。"); return false; } else { $("CommentForm").submit(); } } /******************************************** 头部广告语 ********************************************/ function correctPNG() { for(var i=0; i" img.outerHTML = strNewHTML i = i-1 } } } //window.attachEvent("onload", correctPNG); /************************************************************ 首页滚动的图片 ************************************************************/ function MarqueeControl(ContainID,Directions,LeftBtn,RightBtn) { var marquee1 = new Marquee(ContainID) marquee1.Direction = Directions; marquee1.Step = 1; marquee1.Width = 159; marquee1.Height = 250; marquee1.Timer = 30; marquee1.DelayTime = 0; marquee1.WaitTime = 0; marquee1.ScrollStep = 1; // $(LeftBtn).onclick = function(){marquee1.Direction=2;}; // $(RightBtn).onclick = function(){marquee1.Direction=3;}; marquee1.Start(); } /************************************************************ 在线客服 ************************************************************/ function getPosition() { var top = document.documentElement.scrollTop; var left = document.documentElement.scrollLeft; var height = document.documentElement.clientHeight; var width = document.documentElement.clientWidth; return {top:top,left:left,height:height,width:width}; } function QuickPostion(objID) { var obj = document.getElementById(objID); window.onscroll = function (){ var Position = getPosition(); obj.style.top = (Position.top) + 140 +"px"; obj.style.right = "6px"; }; } function QuickPostions(objID,adid) { var obj = document.getElementById(objID); var ad = document.getElementById(adid); window.onscroll = function (){ var Position = getPosition(); obj.style.top = (Position.top) + 140 +"px"; obj.style.right = "6px"; ad.style.top = (Position.top) + 140 +"px"; ad.style.left = "6px"; }; } // *** Cookies *** function setCookie(name,value) { var Days = 1; var exp = new Date(); //new Date("December 31, 9998"); exp.setTime(exp.getTime() + Days*24*60*60*1000); document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + "; path=/"; } function getCookie(name) { var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)"); if(arr=document.cookie.match(reg)) return unescape(arr[2]); else return null; } function delCookie(name) { var exp = new Date(); exp.setTime(exp.getTime() - 1); var cval=getCookie(name); if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString(); } // *** 地址重组 *** function GetThisAllRequest() { var url =window.location.search; //获取url中"?"符后的字串 var thisquest=""; if(url.indexOf("?") != -1) { thisquest=url.slice(1); } return thisquest; } function GetUserID() { var url =window.location.search; //获取url中"?"符后的字串 var thisquest=""; if(url.indexOf("/?") && url.indexOf("=") == -1) { thisquest=url.slice(1); } return thisquest; } function GetThisRequest(rename) { var url =window.location.search; //获取url中"?"符后的字串 var thisquest=""; if(url.indexOf("?") != -1) { var str = url.slice(1); strs = str.split("&"); for(var i = 0; i < strs.length; i ++){ if (rename==strs[i].split("=")[0]){ thisquest=unescape(strs[i].split("=")[1]); } } } return thisquest; } //document.write(GetUserID()); Promotion() function Promotion() { var SiteUrl=window.location.hostname; if(GetUserID().length>0){ var UserID=GetUserID(); }else{ var UserID=GetThisRequest('UserID'); } var PID=GetThisRequest('id'); var UID=GetThisRequest('UserID'); if( PID && UID ){ var testme=getCookie('Promotion_PID'); if(testme!==null){ if(testme.indexOf(","+PID+",")==-1){ setCookie('Promotion_PID',testme+PID+"," ); } }else{ setCookie('Promotion_PID',","+PID+","); } } // if(PID){ // setCookie('Promotion_PID',PID); // } if(UserID){ setCookie('Promotion_UserID',UserID); }else{ setCookie('Promotion_UserID',""); } if(SiteUrl){ setCookie('Promotion_SiteUrl',SiteUrl); }else{ setCookie('Promotion_SiteUrl',""); } } function setCopy(_sTxt){try{clipboardData.setData('Text',_sTxt)}catch(e){}} /************************************************************ 疑问提交与验证 ************************************************************/ function checkquestion(phone,email){ var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; if(phone=="" || email==""){ $("question").innerHTML="× Phone or E-mail is empty!"; return false; } if(email.match(reg)==null){ $("question").innerHTML="× E-mail is Mistake!"; return false; } newid=$("txtid").value; url="check.html?type=checkquestion&phone=" + escape(phone) + "&email=" + escape(email) + "&newid=" + escape(newid) + "&x=" + Math.random(); if(go_xmlhttp(url,goto_question) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goto_question(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="0"){ $g("question","×"); return true; }else if(root=="1"){ $g("question","√ Our professor explain to you by short message or E-mail as soon as posible!"); return true; }else if(root=="2"){ $g("question","× E-mail is Mistake!"); return false; }else if(root=="3"){ $g("question","× Mobil Phone is Mistake!"); return false; }else{ $g("question","× 未知错误!"); return false; } return false; } } return false; } /************************************************************ 联系我们 ************************************************************/ function checkcontent(){ var txtname=$("txtname").value; var txttel=$("txttel").value; var txtemail=$("txtemail").value; var txtmsn=$("txtmsn").value; var txtbody=$("txtbody").value; url="check.html?type=checkcontent&value[name]="+ escape(txtname) +"&value[tel]="+ escape(txttel) +"&value[mail]="+ escape(txtemail) +"&value[msn]="+ escape(txtmsn) +"&value[body]="+ escape(txtbody) +"&x=" + Math.random(); if(go_xmlhttp(url,goto_content) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goto_content(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { // alert(root); if(root=="1"){ alert("Success"); LocationToMe(); return true; }else if(root=="2"){ alert("Name is empty"); return false; }else if(root=="3"){ alert("Tel is empty"); return false; }else if(root=="4"){ alert("E-Mail is empty"); return false; }else if(root=="41"){ alert("E-Mail is Mistake"); return false; }else if(root=="5"){ alert("Msn is empty"); return false; }else if(root=="51"){ alert("Msn is Mistake"); return false; }else if(root=="6"){ alert("Content is empty"); return false; }else{ alert("Mistake"); return false; } return false; } } return false; } /************************************************************ 告诉我的朋友 ************************************************************/ function checkfriend(){ var txtname=$("your_name").value; var txtemail=$("your_email").value; var txtfname=$("friend_name").value; var txtfmail=$("friend_email").value; var txtfriendid=$("tells_friend_id").value; var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; if(txtfriendid==""){ $g("msgfriend_email_msg","× I'm sorry, Wrong"); return false; }else{ $g("msgyour_name","√"); } if(txtname==""){ $g("msgyour_name","× Your name is empty"); return false; }else{ $g("msgyour_name","√"); } if(txtemail==""){ $g("msgyour_email","× Your Email is empty"); return false; }else if(txtemail.match(reg)==null){ $g("msgyour_email","× Your Email is Mistake"); return false; }else{ $g("msgyour_email","√"); } if(txtfname==""){ $g("msgfriend_name","× Your friend name is empty"); return false; }else{ $g("msgfriend_name","√"); } if(txtfmail==""){ $g("msgfriend_email","× Your friend Email is empty"); return false; }else if(txtfmail.match(reg)==null){ $g("msgfriend_email","× Your friend Email is Mistake"); return false; }else{ $g("msgfriend_email","√"); } url="check.html?type=checkfriend&value[name]="+ escape(txtname) +"&value[email]="+ escape(txtemail) +"&value[fname]="+ escape(txtfname) +"&value[fmail]="+ escape(txtfmail) +"&value[proid]="+ escape(txtfriendid) +"&x=" + Math.random(); if(go_xmlhttp(url,goto_friend) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goto_friend(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { // alert(root); if(root=="1"){ $g("msgfriend_email_msg","Success!send a email to your friend!"); return true; }else if(root=="11"){ $g("msgfriend_email_msg","× I'm sorry,Have a wrong when send then email!"); return false; }else if(root=="6"){ $g("msgfriend_email_msg","× I'm sorry, Wrong"); return false; }else if(root=="2"){ $g("msgyour_name","× Your name is empty"); return false; }else if(root=="3"){ $g("msgyour_email","× Your Email is empty"); return false; }else if(root=="31"){ $g("msgyour_email","× Your Email is Mistake"); return false; }else if(root=="4"){ $g("msgfriend_name","× Your name is empty"); return false; }else if(root=="5"){ $g("msgfriend_email","× Your Email is empty"); return false; }else if(root=="51"){ $g("msgfriend_email","× Your Email is Mistake"); return false; }else{ $g("msgfriend_email_msg","× Mistake"); return false; } return false; } } return false; } /************************************************************ 加入收藏夹 ************************************************************/ function checkcollect(id){ url="check.html?type=checkcollect&id="+ escape(id) +"&x=" + Math.random(); if(go_xmlhttp(url,goto_collect) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goto_collect(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="2"){ alert("Mistake"); return true; }else if(root=="3"){ alert("No Login"); return false; } alert(root); if(root=="1"){ alert("Success"); return true; }else if(root=="0"){ alert("Name is empty"); return false; } return false; } } return false; } /************************************************************ 订阅邮件 ************************************************************/ function check_post_email(){ var txtemail=$("post_email").value; var reg = /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/; $("msg_post_email").style.display=""; $("msgpost_email_submit").style.display="none"; $g("msgpost_email","Loading..."); if(txtemail=="" || txtemail.match(reg)==null){ $g("msgpost_email","× The E-mail is Mistake"); return false; } url="check.html?type=checkpostemail&email="+ escape(txtemail) +"&x=" + Math.random(); if(go_xmlhttp(url,goto_post_email) == "error") { alert("网络出现故障,请稍候重试。"); } return true; } function goto_post_email(){ if(cncity_xmlHttp.readyState == 4) { var root = cncity_xmlHttp.responseText; if(root == null) { alert("网络出现故障,请稍候重试,"); } else { if(root=="0"){ $g("msgpost_email","I'm sorry, Wrong"); return false; } if(root=="1"){ $g("msgpost_email","Success"); return true; }if(root=="2"){ $g("msgpost_email","The E-mail is Mistake"); return false; }if(root=="3"){ $g("msgpost_email","The E-mail is already exists."); //$g("msgpost_email","The E-mail is already exists.
Do you want to unsubscribe!"); //$("msgpost_email_submit").style.display=""; return false; } return false; } } return false; }