2013-11-25 1 views
11

これは私が私のHTML5アンカータグ(IOS)

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

に持っているもので、クロム、FF上で正常に動作し、アンドロイドが、動作していないようiPadで。

+1

をとあなたが働いていないことは、正確に何を意味するのでしょ –

+0

をクリックすると何も起こりません。 – Monica

+0

Safariでhtmlページを開いたところで、クリックしてリンクが期待通りに処理されました。 http://www.w3schools.com/tags/tryit.asp?filename=tryhtml5_a_href_anchorと同じです。あなたは何が問題なのかを正確に説明しなければなりません。 –

答えて

14

すべてのアンカータグに対して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  
     });  
    } 
}); 
+0

ChromeとFirefox用のクリックはまだ有効ですか? – Monica

+0

はい奥様!クロスプラットフォームのソリューション私の友人。 :) –

+0

大丈夫、ありがとう! – Monica

関連する問題