//加入收藏 function addBookmark(title) { var url=parent.location.href; if (window.sidebar) { window.sidebar.addPanel(title, url,""); } else if( document.all ) { window.external.AddFavorite( url, title); } else if( window.opera && window.print ) { return true; } } //设置首页 function setHome(obj,vrl){ try{ obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl); } catch(e){ if(window.netscape) { try { netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch (e) { alert("抱歉!您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”,点击“加入收藏”后忽略安全提示,即可设置成功。"); } var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); prefs.setCharPref('browser.startup.homepage',vrl); } } } var MY=new Object(); //Cookie读取函数 MY.Cookie = { set:function(name,value,expires,path,domain) { if(typeof expires=="undefined") { expires=new Date(new Date().getTime()+24*3600*1000); } document.cookie=name+"="+decodeURI(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"; path=/")+((domain)?";domain="+domain:""); }, get:function(name) { var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)")); if(arr!=null) { return decodeURIComponent(arr[2]); } return null; }, clear:function(name,path,domain) { if(this.get(name)) { document.cookie=name+"="+((path)?"; path="+path:"; path=/")+((domain)?"; domain="+domain:"")+";expires=Fri, 02-Jan-1970 00:00:00 GMT"; } } }; //限制图片尺寸 function limitImage(ImgD, areaWidth, areaHeight){ var flag=false; if (!areaWidth) { areaWidth = 600; //图片区域的宽度。 } if (!areaWidth) { areaHeight = 450; //图片区域的高度。 } var image = new Image(); try { image.src = ImgD.src; if(image.width>0 && image.height>0){ flag=true; if(image.width/image.height>= areaWidth/areaHeight){ if(image.width>areaWidth) { ImgD.width=areaWidth; ImgD.height=(image.height*areaWidth)/image.width; } else { ImgD.width=image.width; ImgD.height=image.height; } } else { if(image.height>areaHeight){ ImgD.height=areaHeight; ImgD.width=(image.width*areaHeight)/image.height; } else { ImgD.width=image.width; ImgD.height=image.height; } } } } catch (e) { //nothing } } //带参数的 复制到剪切板 function copyCodes(ele){ if(copy2Clipboard(ele)!=false){ alert("生成的代码已经复制到粘贴板,你可以使用Ctrl+V 贴到需要的地方去了哦! "); } } //复制到剪切板 function copyCode(){ var testCode = ""; testCode += document.title + ' ' + this.location.href; if(copy2Clipboard(testCode)!=false){ alert("生成的代码已经复制到粘贴板,你可以使用Ctrl+V 贴到需要的地方去了哦! "); } } copy2Clipboard=function(txt){ if(window.clipboardData){ window.clipboardData.clearData(); window.clipboardData.setData("Text",txt); } else if(navigator.userAgent.indexOf("Opera")!=-1){ window.location=txt; } else if(window.netscape){ try{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); } catch(e){ alert("您的firefox安全限制限制您进行剪贴板操作,请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试,相对路径为firefox根目录/greprefs/all.js"); return false; } var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); if(!clip)return; var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if(!trans)return; trans.addDataFlavor('text/unicode'); var str=new Object(); var len=new Object(); var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); var copytext=txt;str.data=copytext; trans.setTransferData("text/unicode",str,copytext.length*2); var clipid=Components.interfaces.nsIClipboard; if(!clip)return false; clip.setData(trans,null,clipid.kGlobalClipboard); } } /** * 获取url地址参数 */ function getUrlParam(paramName) { var returnVal=""; try{ var paramUrl=window.location.search; //处理长度 if (paramUrl.length>0) { paramUrl = paramUrl.substring(1, paramUrl.length); var paramUrlArray = paramUrl.split("&"); for (var i=0; i<paramUrlArray.length; i++) { if (paramUrlArray[i].toLowerCase().indexOf(paramName.toLowerCase())!=-1) { var temp=paramUrlArray[i].split("="); if(temp[0].toLowerCase()==paramName.toLowerCase()) { returnVal=temp[1]; break; } } } } returnVal = decodeURIComponent(returnVal); } catch(e) { //nothing }; return returnVal; } //渠道来源记录 try { if (getUrlParam('utm_source')!="" && getUrlParam('utm_medium')!="") { MY.Cookie.set('utm_tag', getUrlParam('utm_source') + '|' + getUrlParam('utm_medium') + '|' + getUrlParam('utm_place'), new Date(new Date().getTime()+1*24*3600*1000), '/', 'game.10086.cn'); } } catch(e) { //nothing }