<script type="text/javascript">

var URL = document.location.toString();
var device = "&device=PC";
var useragent = navigator.userAgent;
useragent = useragent.toLowerCase();

if( URL.lastIndexOf("device")==-1 )//找不到drvice
{
if( useragent.indexOf('iphone') != -1 ) device = "&device=iphone";
else if( useragent.indexOf('ipad') != -1 ) device = "&device=ipad";
else if( useragent.indexOf('android') != -1 ) {
if( ConsiderLimits() )
{
device = "&device=android_pad"; // pad
}else{
device = "&device=android_phone"; // phone
}
}
URL = URL + device;
location.replace(URL);
}

function ConsiderLimits() {
if( screen.width >= 1024 && screen.height >= 600 )
return 1;
return 0;
}
</script>

JSP
//使用request.getParameter("device")抓取

Will(小威) 發表在 痞客邦 PIXNET 留言(0) 人氣()