Import HTML via rel link not supported in Safari?

I use this code to import only partial divs from one page to another:

<!DOCTYPE html>
<html>
<head>
   <link rel="import" href="html/source.html">
</head>
<body>
<script>
    var link = document.querySelector('link[rel="import"]');
    var content = link.import;
    var el = content.querySelector('#mainModals');
    document.body.appendChild(el.cloneNode(true));
</script>
</body>

It works fine in Chrome, but it doesn't work in Safari.

Error: TypeError: undefined is not an object (rating "content.querySelector")

+4
source share
1 answer

HTML import currently has very limited browser support , as they are a very new feature (so new that the specification is only in the status of a working draft).

They are supported by Chrome 36 and other browsers using the Blink browser engine.

IE, Firefox, and Safari do not currently support them at all.

+4
source

All Articles