在Chrome浏览器中无法选择SVG格式的提示信息。

问题描述 投票:0回答:1

我使用SVG文件格式来绘制图形,我希望当我点击一个节点时,一些信息会以警告的形式弹出,信息会和工具提示一样,所以我把它写成了下面的样子,但是我发现了一些奇怪的事情,当我在字符串中加入'
'时,现在它可以在警告框中选择文本。

<g id="a_node11502"><a xlink:title="Youtiao (Chinese Deep Fried Donuts)" href="#" onclick="alert(this.getAttribute('xlink:title'))">

但是,我发现了一些奇怪的事情,当我在字符串中加入'&#10;'时,现在可以在提示框中选择文本。但是,当我把'&#10;'放在字符串中时,现在可以在提示框中选择文本了,但是 火狐允许它被选中,因此我认为这在chrome中是一种奇怪的事情。因此,我认为这在chrome中是一种奇怪的事情。我知道'&#10;'是一个换行符。你知道如何解决这个问题吗?

<g id="a_node11502"><a xlink:title="Youtiao (Chinese Deep Fried Donuts)&#10;" href="#" onclick="popup(this)">

形象

操作系统: Ubuntu 18.04

非常感谢您的帮助

javascript google-chrome svg alert
1个回答
0
投票

对于那些试图做我所做的事情的人。

似乎需要进行后期处理。

<a xlink:title="YAKULT is delicious" href="#" onclick="popup(this)">
<script>
function popup(e){
    alert(e.getAttribute('xlink:title'));
    navigator.clipboard.writeText(e.getAttribute('xlink:title'))
  .then(() => {
    console.log('Text copied to clipboard');
  })
  .catch(err => {
    // This can happen if the user denies clipboard permissions:
    console.error('Could not copy text: ', err);
  });


}
</script>
© www.soinside.com 2019 - 2024. All rights reserved.