Created
November 22, 2017 10:23
-
-
Save vovs03/694aa9a65179932e09bfcb9ed08df36c to your computer and use it in GitHub Desktop.
HTML Imports
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template> | |
<h1>Hello World!</h1> | |
<!-- Img is not requested until the <template> goes live. --> | |
<img src="world.png"> | |
<script>alert("Executed when the template is activated.");</script> | |
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<link rel="import" href="import.html"> | |
</head> | |
<body> | |
<p>Проверка работы - ниже вставка, импорт.</p> | |
<div id="container"></div> | |
<script> | |
var link = document.querySelector('link[rel="import"]'); | |
// Clone the <template> in the import. | |
var template = link.import.querySelector('template'); | |
var clone = document.importNode(template.content, true); | |
document.querySelector('#container').appendChild(clone); | |
</script> | |
</body> | |
</html> |
пробовал локально, не работает, другой вариант отправил на сервер, код работает
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Errors:
Access to Imported resource at 'file:///C:/test/NEW/intro1.html' from origin 'null' has been blocked by CORS policy: Invalid response. Origin 'null' is therefore not allowed access.
Uncaught TypeError: Cannot read property 'querySelector' of null
at index.html:13