Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在IE11中使用本机JS在SVG中插入?_Javascript_Svg_Title_Internet Explorer 11 - Fatal编程技术网

Javascript 如何在IE11中使用本机JS在SVG中插入?

Javascript 如何在IE11中使用本机JS在SVG中插入?,javascript,svg,title,internet-explorer-11,Javascript,Svg,Title,Internet Explorer 11,我明白了: <svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="mydefs.svg#hello"><title>hello world</title></use></svg> 但是,在退出函数后,IE11只是用mydefs.svg中定义的路径替换svg的内部内容,完全忽略了我试图放入其中的动态标题标记 如果我将标题直接放在mydefs.svg中

我明白了:

<svg><use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="mydefs.svg#hello"><title>hello world</title></use></svg>
但是,在退出函数后,IE11只是用mydefs.svg中定义的路径替换svg的内部内容,完全忽略了我试图放入其中的动态标题标记

如果我将标题直接放在mydefs.svg中,那么我将看到标题标记,但是当鼠标悬停时,工具提示也不会显示

在IE11中,为SVG生成标题标签的正确方法是什么?

t是什么?如果您希望生成与示例SVG相同的结果,是否应该使用该行。appendChildtitle?是的,是title,t应该是我尝试为textContent设置的hello world。创建此问题时,只需复制粘贴错误。
// "this" is the svg element already
var use = document.createElementNS("http://www.w3.org/2000/svg", "use");
use.setAttributeNS("http://www.w3.org/1999/xlink", "xlink:href", "mydefs.svg#hello");

var title = document.createElementNS("http://www.w3.org/2000/svg", "title");
title.textContent = "hello world";

this.appendChild(use);
this.insertBefore(title, use);