简体   繁体   English

仅在单击链接时显示文本

[英]Show text only when link is clicked

I have a client which owns an index site. 我有一个拥有索引站点的客户端。 The index includes phone numbers for the companies listed. 该索引包括列出的公司的电话号码。 I want the phone number to not show up in search results and only show up when the user enters the index page and clicks a link. 我希望电话号码不显示在搜索结果中,而仅在用户进入索引页面并单击链接时显示。 I don't currently use jQuery on the site, but I'm not apposed to adding it, if it makes things easier (I'm guessing it will). 我目前不在该网站上使用jQuery,但我不赞成添加它,如果它使事情变得容易的话(我猜想会)。 Any ideas on how to implement this? 关于如何实现这一点的任何想法?

Personally, I would not rely on JavaScript to show information to my customers how they can contact me. 就个人而言,我不会依靠JavaScript向客户显示信息,让他们知道如何与我联系。 Customers with deactivated JavaScript would be unable to contact me. 使用停用的JavaScript的客户将无法与我联系。

A solution would be to simply exclude the page with the phone numbers through a ROBOTS.TXT file. 一种解决方案是通过ROBOTS.TXT文件简单地排除带有电话号码的页面。

Or, you could render the numbers as images. 或者,您可以将数字渲染为图像。

如果您想使用JavaScript在搜索引擎中隐藏电话号码,则可以将字符串拆分,然后将其与document.write连接起来:

document.write('Phone Number: ###' + '####');

It's important to develop code to work with and without JS enabled, its part of the W3C Accessability guides and good practice.. 重要的是,开发可在启用和未启用JS的情况下工作的代码,W3C可访问性指南的一部分和良好实践。

This maybe a little helpful 这可能会有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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