如何在网页浏览器中定向网页以建立呼叫对话框?

问题描述

单击tel:+1123456789将通过电话/计算机调用呼叫时,我看到了链接

我遇到了一些链接,例如

https://ctrlq.org/call/9876543210

单击时将直接调用方法,甚至不打开页面

那怎么可能?

请注意,没有手动单击超链接

解决方法

检查您共享的链接的标头响应,其中有302重定向,其中包含新位置tel:9876543210,它会提示浏览器呼叫该号码。

HTTP/1.1 302 Moved Temporarily
Date: Tue,06 Oct 2020 15:42:10 GMT
Server: Apache
Location: tel:9876543210
Cache-Control: max-age=600
Expires: Tue,06 Oct 2020 15:52:10 GMT
Vary: User-Agent,Accept-Encoding
Content-Encoding: gzip
Content-Length: 20
Keep-Alive: timeout=2,max=100
Connection: Keep-Alive
Content-Type: text/html; charset=UTF-8

如果您正在运行Apache服务器,则可以查阅Apache .htaccess TutorialApache URL Rewriting Guide。如果您的网站托管在运行其他软件的服务器上,请与托管商联系以获取更多详细信息。

基于浏览器的解决方案也可以用于设置重定向,其中一些是covered in this post

,

从@mhawksey的答案中我可以做到这一点,它将成功重定向

使用此链接传递数字:https://yoursite.com/redirect.htm?tel=+1234567890

将此文件上传到驱动器根目录。

<!DOCTYPE html>
<html>
  <head>
    <base target="_top">
  </head>
<body onload='window.location = "tel:" + new URL(window.location.href).searchParams.get("tel");'>
</body>
</html>
,

我没有真正理解您的意思,因为没有手动单击超链接。但是,如果您需要一个可以调用的链接,则可以使用带有tel属性的锚标记。

<a href="tel:987654321">Call 987654321</a>