Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does createElementNS work consistently offline? Specifically with the SVG namespace

I can't find any good information on this, best thread I found was this:createElement vs. createElementNS

But I don't understand how a line like this: var path = document.createElementNS('http://www.w3.org/2000/svg', 'path');

Would be able to work offline. Is the string arbitrary? If you follow the link it brings you to a meaningless site.

When trying that line in a Chrome both offline and online it works. But when I try on my laptop offline, it doesn't work. After connecting online it does work. So I'm assuming the namespace is cached somewhere? I don't want to clean my chrome to test this but I may have to.

Was wondering if anything could help shed some light on this?

like image 968
A O Avatar asked Oct 31 '22 11:10

A O


1 Answers

http://www.w3.org/2000/svg is not only an URL it is an XML namespace. XML namespaces can be URLs and must be URIs. An example for an namespace that is not an URL would be urn:ietf:params:xml:ns:vcard-4.0. The page is not meaningless. It contains informations about the XML namespace and links.

XML namespaces define the format/standard an element or attribute node is part of. They have to be unique, using a domain as a part of it avoids conflicts and allows for some documentation.

The reason for you problem might be that you open the html file directly from the file system and the HTTP headers are missing. This changes how a browser handles a file. How depends on the browser the OS and the file.

like image 79
ThW Avatar answered Nov 15 '22 05:11

ThW