HTML 可用性问题 - (双击)选择文本
众所周知,在浏览器中双击一个单词可以选择它,三次单击可以选择整个段落。
我正在调整一个 wiki,其中会自动创建匿名用户的签名,它们看起来像:
--- //
“---”生成一个 — , // 用于斜体文本并生成 。
这就是我现在的工作方式,我对其进行了调整。现在我想知道可用性。
我的问题是:如何生成标记,以便在双击 IP 地址时,将选择整个地址并且仅选择该地址?
标记语言并不重要,您可以提供 HTML 格式的解决方案,但最好是专门针对 wiki (dokuwiki) 的解决方案。
谢谢
As you well know, double clicking on a word in a browser selects it, triple clicking selects the entire paragraph.
I'm tweaking a wiki, where signatures for anonymous users are created automatically and they look like:
--- // <ip.ad.dr.ess> //
The "---" generates a — , // is for italic text and generates <em></em>.
This is how it works now, as I tweaked it. Now I'm wondering about the usability.
My question is: how to generate the markup such that upon a double click on the ip address, the whole address and only the address will be selected?
The markup language doesn't matter, you may provide a solution in HTML, but one specific for wikis (dokuwiki) is preferable.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
感谢大家,但我已经设法通过使用无边框的只读文本字段集和网站背景的背景色来做到这一点。
双击按预期工作,无需依赖客户端脚本。
Thanks to everyone, but I've managed to do it by using a readonly text field set without borders and with the background color of the background of the website.
Double clicking works as expected, without relying on client-side scripting.
使用 HTML 无法做到这一点。也许用 JavaScript。基本上,您只需检测特定区域中的双击,然后选择适当的文本。
编辑:
以下是在 W3C 兼容浏览器中执行此操作的方法(例如 Firefox,它可能无法在 IE 中工作,IE 不是 W3C 兼容浏览器并使用不同的文本选择模型):
You can't do that with HTML. Maybe with Javascript. Basically, you just detect double clicks in a certain area and then select the appropriate text.
EDIT:
Here's how to do it in W3C compliant browser (e.g. Firefox, it probably won't work in IE, which isn't a W3C compliant browser and uses different text selection model):