3

I have a responsive django app that shows a phone number on a button click. I'd like to trigger the phone call on mobile devices. How do I detect the device such that the call to phone action only happens on mobile devices, but on desktop it only shows text? I've seen this post How to trigger a phone call when clicking a link in a web page on mobile phone but it doesn't help much.

 <input onclick="change()"  class="btn btn-primary phone" type="button" value="Show Phone Number" id="myButton1" />

      <script type="text/javascript">
      function change() 
      {
        var elem = document.getElementById("myButton1");
        elem.value = "" + {{contact_no}};

      }
      </script>
Community
  • 1
  • 1
James L.
  • 1,143
  • 22
  • 52
  • [This post](http://stackoverflow.com/questions/11381673/detecting-a-mobile-browser) might help. – ekrah Feb 20 '15 at 17:03
  • Did you search around? http://stackoverflow.com/questions/17345177/use-jquery-to-detect-whether-a-device-can-make-telephone-calls-supports-tel – epascarello Feb 20 '15 at 17:04
  • Have you tried using a `callto://` [URI scheme](http://en.wikipedia.org/wiki/URI_scheme)? I'm not sure its a global standard (as it seems to be a Skype-centric spec, but it might be something that mobile phone browsers handle well. – ThorSummoner Feb 20 '15 at 18:57
  • What is wrong with displaying a phone link to all people? People use their (desktop) computers to make calls all the time. Do you know Skype? Just use `` and stop creating hurdles. – allcaps Feb 20 '15 at 21:47
  • @allcaps my target audience doesn't use Skype to make calls on their computers! I just need the call to phone action happen only on phones and show simple number text on computers. – James L. Feb 21 '15 at 16:58
  • Have you looked at this `Call us free!` – Ali Gajani May 01 '15 at 10:54

1 Answers1

1

use following

< a href='tel:+9190123456' >

But before using this you must be use a condition for mobile device and computer to trigger call with number as computer does not support any call feature .

karan
  • 3,319
  • 1
  • 35
  • 44
Tariq
  • 188
  • 1
  • 15