问题
Can a pure SVG document arriving at a browser, support a favicon.ico specification? My case is machine generated pure SVG, no html>
or <head>
tags available.
回答1:
Yes, since SVG is XML, you can add the (x)html link element anywhere in the svg:
<link xmlns="http://www.w3.org/1999/xhtml" rel="shortcut icon"
href="favicon.ico" />
There's absolutely no need to wrap this in foreignObject. I recommend putting the link element as a child of a <defs> element though, just to let the svg engines know that it can be skipped for the actual svg rendering.
Do note that this isn't "pure" svg, it's an xhtml/svg hybrid - but it should work in all the browsers that support svg.
来源:https://stackoverflow.com/questions/13324547/can-pure-svg-document-specify-a-favicon-ico