锚定标签不适用于iPhone / iPod Touch / iPad的Safari(ios)

这就是我的HTML5

<div class="google-play"> <a href="http://example.com" role="button"> <img src="img/google-play-btn.png"/> </a> </div> 

并在铬,FF,Android上正常工作,但似乎并没有在iPad上工作。

在所有的锚点标签上使用通过jQuery的touchend事件。 例如:

 $(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的特定function,请检查“设备”是否为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 }); } });