function checkIPAD(){ var userAgent = window.navigator.userAgent.toLowerCase(); if (userAgent.indexOf('ipad') != -1 && $.cookie('device')!='pc') { if(window.confirm('本页有iPad版,用iPad阅览吗?')){ var url = decodeURIComponent(window.location.pathname); iPadURL = url.replace("/ch/pavilion/","/ch/pavilion/tab/"); location.href = iPadURL; }else{ $.cookie('device', 'pc',{ path: '/' }); } } } $(function(){ checkIPAD(); });