简体   繁体   中英

jquery show not working with href tel click on android chrome

I created a webpage for mobile devices that I want to open a jquery ui dialog and then do the click of the number when link is clicked. all I did was a

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

and then a

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

The link is href="tel:2342342345" .

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:

If I do a settimeout on the click, if it is less than about a second, it will not open the dialog and bring up the phone. If it is over a second, it will open the dialog and then just ignore the phone. I tried add an on focus event to the window thinking once the phone call is done and they go back to the chrome, it would open the dialog, but it does not. I tried adding an ajax call before the click to open the window later, but that seems to work like the settimeout does. If it is quick, it just opens the phone interface and never pops up the dialog and if it is slow, it never opens the phone interface.

I also tried it by just creating a div with display:none and then doing a $('#div').show() and it acts exactly the same.

Not sure if it will work on other phone types as I have not tested.

I also tried adding an onblur event to do this, but that is not triggered either on android while working on desktop.

 <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>

unable to understand what you want . I think you want this according to your writing "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:"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM