最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How does createElementNS work? - Stack Overflow

programmeradmin4浏览0评论

I don't really understand how does createElementNS works. For example:

svg = "";
group = document.createElementNS(svg,"g");

Does this connect to the specified namespace and gets the definitions for the g element?

If so... if placed inside a for there will be some kind of request to the specified url?

Is there another way to create a g element? One that does not require online connection?

I don't think so because I don't see any requests going there but still... is a bit ambiguous.

The reason why I'm asking is that something is greatly slowing my script down and I don't know exactly what.

I don't really understand how does createElementNS works. For example:

svg = "http://www.w3/2000/svg";
group = document.createElementNS(svg,"g");

Does this connect to the specified namespace and gets the definitions for the g element?

If so... if placed inside a for there will be some kind of request to the specified url?

Is there another way to create a g element? One that does not require online connection?

I don't think so because I don't see any requests going there but still... is a bit ambiguous.

The reason why I'm asking is that something is greatly slowing my script down and I don't know exactly what.

Share Improve this question edited Jan 8, 2018 at 11:15 ekad 14.6k26 gold badges46 silver badges48 bronze badges asked Feb 24, 2012 at 10:51 zozozozo 8,59219 gold badges83 silver badges141 bronze badges 1
  • I don't think an html page retrieves any data from the namespace address. When defining a namespace in other languages (C++, Java), it is essentially a string label. I think that people use the address because it refers to the exact specification of the namespace they are using. For instance, if you had a namespace called "svg", that gives someone looking at the code no additional info. If you input the address into your web browser, you get every detail of the namespace capabilities. Afaik, it's just a great way to organize namespaces. It also separates different versions of the standard. – NuclearPeon Commented Feb 1, 2013 at 20:18
Add a ment  | 

1 Answer 1

Reset to default 11

Does this connect to the specified namespace and gets the definitions for the g element?

No. You can't "connect" to a namespace. http://www.w3/2000/svg is a unique identifier for the namespace, but namespaces are not URLs. The software handing the DOM needs to understand SVG (and will have the namespace mapped internally to its understanding of it).

The URL http://www.w3/2000/svg is a document that tells readers where to find more information about SVG, but that is just the authors being helpful, there is no programatic significance of a document existing there.

发布评论

评论列表(0)

  1. 暂无评论