从手机禁用悬停的脚本是打开自窗口上的链接,我该如何解决这个问题

the script for disable hover from mobiles is open the link on self windows how i can fix that?

本文关键字:何解决 解决 问题 悬停 脚本 手机 窗口 链接      更新时间:2023-09-26

>我的网站上的链接有问题,当我点击一个链接时必须转到这个链接,但我必须在链接上点击两次,然后链接打开,我使用此 jquery 脚本解决了这个问题:

$(document).ready(function() {
   $('a').on('click touchend', function(e) {
      var el = $(this);
      var link = el.attr('href');
      window.location = link;
   });
});
当我

单击它时,我有一个按钮链接必须打开一个新选项卡,但是当我使用此脚本时,链接在新选项卡上打开,而self选项卡两个

不想在新的和自我选项卡上打开链接,我该如何解决?

<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>

<script>$(document).ready(function() {
   $('a').on('click touchend', function(e) {
     var el = $(this);
      el.attr("target", "_blank");
      window.open(el.attr('href'));
   });
});
        </script>
</head>
<body>   
   <a rel="nofollow"  href="partnerwebsite.com" title="black cat print" class="spr buy-it-now">Buy it</a>
</body>
</html>