[英]How to dial USSD CODE by using button on mobile browser
I am trying to dial a USSD Code using this code 我正在尝试使用此代码拨打USSD代码
<button onclick="document.location.href = 'tel:*556#'">Check balance</button>
but is not working on mobile 但不适用于手机
You should rely on anchor tags for that since you want to open another app via a hyperlink. 您应该依靠锚标记,因为您想通过超链接打开另一个应用程序。
Using the following should work for you 使用以下内容应该适合您
<a href="tel:*556%23">Check balance</a>
%23
is the the url encoded value of #
. %23
是#
的url编码值。 The rule of thumb is to encode the url of your link (number). 经验法则是对链接的网址(数字)进行编码。 You can use
encodeURIComponent('your-number-here')
to do that 您可以使用
encodeURIComponent('your-number-here')
做到这一点
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.