标签:
针对不同客户端下载链接的页面响应样式不一样,更人性点而已 //匹配客户端类型 var isAndroid = navigator.userAgent.toLowerCase().match(/android/i) == "android"; var isIphone = navigator.userAgent.toLowerCase().match(/iphone os/i) == "iphone os"; var isIpad = navigator.userAgent.toLowerCase().match(/ipad/i) == "ipad"; var isWin = navigator.userAgent.toLowerCase().match(/windows phone/i) == "windows phone"; var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel"); //定义几个函数,获取url中的get参数 (function($) { $.extend({ urlGet:function() { var aQuery = window.location.href.split("?"); //取得Get参数 var aGET = new Array(); if(aQuery.length > 1) { var aBuf = aQuery[1].split("&"); for(var i=0, iLoop = aBuf.length; i<iLoop; i++) { var aTmp = aBuf[i].split("="); //分离key与Value aGET[aTmp[0]] = aTmp[1]; } } return aGET; } }) })(jQuery); $(document).ready(function(){ var curr_url = window.location.href; var host = window.location.host; var GET = $.urlGet(); var curr_url = GET[‘url_download‘]; if(isAndroid || isIpad || isIphone || isWin){ //手机端的样子 $(".addthis_sharing_toolbox").show(); //ajax请求,匹配参数获得返回值 if(curr_url.indexOf(".exe")!=-1||curr_url.indexOf(".dmg")!=-1){ $.ajax({ url:‘http://‘+host+‘/index.php/Index/mobile_url‘, type:‘post‘, data:{url:curr_url}, async : true, error:function(){ alert(‘error‘); }, success:function(data){ //只是一些样式的控制,不用看 $(".box1").show(); $(".box2").hide(); $(".addthis_sharing_toolbox").show(); $(".discountCode").show(); var json = eval(‘(‘ + data + ‘)‘); $("#win_price").html(json.win_price); $("#mac_price").html(json.mac_price); $("#win_btn").attr(‘href‘,json.win_buy); $("#mac_btn").attr(‘href‘,json.mac_buy); $("#share_code").attr(‘data-url‘,json.skip_url); $("#share_code").attr(‘data-title‘,json.skip_title); } }); } }else{ //pc端的样子,样式的控制不用看 $(".box1").hide(); $(".box2").show(); $("#pc_download").attr(‘href‘,curr_url); location.href=curr_url; }
标签:
原文地址:http://www.cnblogs.com/qiandu/p/4191653.html