这就是我对HTML5的看法
<div class="google-play">
<a href="http://example.com" role="button">
<img src="img/google-play-btn.png"/>
</a>
</div>
并且在chrome,FF,android上工作正常,但似乎无法在iPad上运行。
使用 touchend
所有锚标签上的jQuery事件。例如:
$(function () {
$('a').on('click touchend', function() {
var link = $(this).attr('href');
window.open(link,'_blank'); // opens in new window as requested
return false; // prevent anchor click
});
});
如果您只想制作上述iPhone和iPad特定功能,请检查“设备”是否是iPad,iPhone等。如下所示:
$(function () {
IS_IPAD = navigator.userAgent.match(/iPad/i) != null;
IS_IPHONE = (navigator.userAgent.match(/iPhone/i) != null) || (navigator.userAgent.match(/iPod/i) != null);
if (IS_IPAD || IS_IPHONE) {
$('a').on('click touchend', function() {
var link = $(this).attr('href');
window.open(link,'_blank'); // opens in new window as requested
return false; // prevent anchor click
});
}
});