jQuery ตรวจสอบว่าเปิดเว็บโดยใช้ iPhone iPod หรือ iPad
ช่วงนี้งานทำเว็บต้องให้ Support iPhone iPad ตามเทคโนโลยี ดังนั้นเลยต้องใช้ jQuery Javascript Framework มาช่วยตรวจสอบว่าผู้ใช้เปิดเว็บโดยใช้ iPhone iPod หรือ iPad รึเปล่า ตัวอย่างโค้ดตามด้านล่างเลยครับ สั้นๆง่ายๆ
jQuery(document).ready(function($){ var deviceAgent = navigator.userAgent.toLowerCase(); var agentID = deviceAgent.match(/(iphone|ipod|ipad)/); if (agentID) { // ใส่โค้ดที่นี่ถ้าเปิดจาก iphone ,ipod,ipad } });
ที่มา : http://www.jquery4u.com/mobile/jquery-detect-mobile-devices-iphone-ipod-ipad/