jquery 显示无法使用 href 电话点击 android chrome

jquery show not working with href tel click on android chrome

我为移动设备创建了一个网页,我想打开一个 jquery ui 对话框,然后在单击 link 时单击数字。 我所做的只是

$( "#dialog" ).dialog( "open" ) 

然后

$("#link").click().  

link 是 href="tel:2342342345"

如果我不在移动设备上,它会正常打开对话框,但显然会忽略点击,因为它不是 phone。我已经尝试了一个小时不同的东西,这里是一些结果:

如果我在点击时设置超时,如果不到一秒,它不会打开对话框并显示 phone。如果超过一秒,它将打开对话框,然后忽略 phone。我尝试向 window 添加一个焦点事件,认为一旦 phone 调用完成并且他们返回 chrome,它会打开对话框,但它不会。我尝试在单击之前添加一个 ajax 调用以稍后打开 window ,但这似乎像 settimeout 一样工作。如果是quick,则只打开phone界面,不弹出对话框,如果慢,则不打开phone界面。

我也试过用display:none创建一个div,然后做一个$('#div').show(),结果完全一样。

不确定它是否适用于其他 phone 类型,因为我还没有测试过。

我也尝试添加一个 onblur 事件来执行此操作,但在桌面上工作时 android 也没有触发。

<html>
  <head>
    <title></title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="">
   <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <style></style>
  </head>
  <body>
    <div>
    
    <a href="#" id="link">call</a>
    <!--open browser devtool and check in mobile divase -->
    </div>
    <script>
    $(document).ready(function(){

        if(window.innerWidth < 769){
            $('#link').attr("href", 'tel:2342342345');
        }
        if(window.innerWidth > 769){
            $('#link').attr("href", '#');
        }
        console.log($('#link').attr("href"))
    })
    </script>
  </body>
</html>

无法理解你想要什么。根据你的写作,我认为你想要这个 "If I am not on mobile, it will open the dialog fine, but obviously, ignores the click because it is not a phone. I have been trying different things for an hour and here are some of the results:"