3

I have a HTML file with inline SVG, which in turn refers to SVG elements in external SVG file with library elements. It uses a <use> elements with xlink:href="Library.svg#libraryShapeID". It works as a breeze in Opera and Firefox, but doesn't work in Safari. I've made a simple test file here:

http://sasq.comyr.com/Stuff/SVG/test01.html

Is it some browser bug or am I doing something wrong? How should I rewrite it to make it work in Safari too?

1201ProgramAlarm
  • 32,384
  • 7
  • 42
  • 56
SasQ
  • 14,009
  • 7
  • 43
  • 43

2 Answers2

4

There was a bug about this on Webkit but it has been fixed for the Version: 420+ BUT the bug for Fragment identifier is still not solved.

Someone gave an answer: Importing external SVG (with WebKit) using XMLHttpRequest. Quite unfortunate but in the meantime, I guess working.

Community
  • 1
  • 1
karlcow
  • 6,977
  • 4
  • 38
  • 72
1

I realize that this is an old question. But as this method of using SVGs has become more popular these days, I wrote a polyfill to make this technique work in browsers that fail to load the external SVG by default. At the time of writing this, IE9+ doesn't support referencing external SVGs in use elements. The polyfill that I wrote is quite simple and lightweight; it detects whether the SVG has failed to load and if so, sends a GET request to fetch it. It will then prepend it to body.

I hope you find it useful. I would appreciate any feedback.

Keyamoon
  • 1,785
  • 17
  • 16