`
化蝶自在飞
  • 浏览: 2306161 次
  • 性别: Icon_minigender_2
  • 来自: 武汉
社区版块
存档分类
最新评论

分析下迅雷旗下游戏网站31345保存到桌面功能的实现

    博客分类:
  • php
阅读更多
网站地址是31345.com,可以看出是迅雷其他的,其 保存到桌面 按钮链接地址是: http://active.game.xunlei.com/shortcut.php  .

直接访问该地址会提示下载,因为我自己做的一个功能也是这样.如果不调用迅雷下载或者提示下载,直接保存到桌面上? 在他的网站上点这个按钮是可以直接保存而不用提示下载确认的.看了下首页代码,针对这个功能的js代码如下:

	function addShortcut(index){
			if(typeof(G)=="undefined"){
				varURL="http://www.31345.com/?recomid=27";
				varTitle="31345小游戏";
			}else{
				varURL=window.location;
				varTitle=G.name;
			}
			var curThunderVer = 0;
			try {
				var dapCtrl = new ActiveXObject("DapCtrl.DapCtrl");
				curThunderVer = dapCtrl.GetThunderVer ("Thunder59", "Install");
			}catch(e){
				curThunderVer = 0;
			}
			if(curThunderVer<2222){
				saveToDesk();
			}else{
				try{
					var url = varURL;
					var paramStr = '-createhomeshelllink '+ url +' -filename '+varTitle;
					var ThunderAgent = new ActiveXObject("ThunderAgent.Agent");
	 				var r=ThunderAgent.ExecuteCommand("XLGame", "XlFlashGame", paramStr);
					if(r==0){
						alert("成功保存到桌面");
					}else{
						alert("添加失败,请自行右键发送到桌面快捷方式.");
					}
				}catch(e){
					saveToDesk();
				}
				
			}
			return false;
	}
	function saveToDesk(){
		if(typeof(G)=="undefined"){
			window.open('http://active.game.xunlei.com/shortcut.php');
			return;
		}
		var form = document.getElementById("saveDestopForm");
		if(form){
			document.body.removeChild(form);
		}
		form = document.createElement("form");
		with(form){
			name = "saveDestopForm";
			id = "saveDestopForm";
			action="http://localhost/shortcut.php";
			target = "_blank";
			method = "post";
			style.display="none";
			//onsubmit="document.charset='GB2312';"
		}
		//form['accept-charset']="GB2312";
		document.body.appendChild(form);
		var u = document.createElement("input");
		with(u){
		name="link";
		type="text";
		}
		u.value=window.location;
		form.appendChild(u);
		var p = document.createElement("input");
		with(p){
		name="ctitle";
		type="text";
		}
		p.value=G.name;
		form.appendChild(p);
		form.submit();
		return false;
	}


调用的方式是:
  <a class="btn_save" href="http://active.game.xunlei.com/shortcut.php" target="_blank" title="保存31345小游戏到桌面" onclick="addShortcut('index'); return false">保存到桌面</a>


哪位牛人分析下?谢谢.
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics