我怎样才能制作一个<a href>仅在移动设备上有效? [英] How can I make an <a href> only active on mobile devices?

查看:18
本文介绍了我怎样才能制作一个<a href>仅在移动设备上有效?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加此代码以使我网站上的联系方式在点击时自动跳转到移动拨号盘/地址簿:

<a href="tel:12345555555">立即致电我们</a>

如何使它在非电话设备(计算机、平板电脑、笔记本电脑)上显示为纯文本,以免返回 404 错误并且无法点击?

很高兴使用 HTML/CSS/JS 的任意组合来实现这一点.

解决方案

不要使用超链接.使用微数据.手机会识别它是一个电话号码并允许点击它,但不会影响正常的网络浏览器.

<div class="tel">12345555555

I want to add this code to make the contact details on my website automatically jump into a mobile dialpad/address book when clicked:

<a href="tel:12345555555">Call Us Now</a>

How can I make it appear as plain text for non-telephone devices (computers, tablets, laptops) so that it doesn't return a 404 error and cannot be clicked?

Happy to use any combination of HTML/CSS/JS to achieve this.

解决方案

Don't use a hyperlink. Use microdata. Mobile phones will recognize that it is a phone number and allow it to be clicked but it won't affect normal web browsers.

<div class="vcard">
    <div class="tel">
        12345555555
    </div>
</div>

这篇关于我怎样才能制作一个&lt;a href&gt;仅在移动设备上有效?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆