Safari 不支持通过 link rel 导入 HTML?
Import HTML via link rel not supported in Safari?
我正在使用此代码仅将部分 div 从一个页面导入到其他页面:
<!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>
它在 Chrome 中工作正常,但在 Safari 中不起作用。
错误是:TypeError: undefined is not an object (evaluating 'content.querySelector')
HTML 导入当前 have very limited browser support since they are a very new feature (so new that the specification 仅处于 工作草案 状态)。
它们受 Chrome 36 及大多数其他使用 Blink 浏览器引擎的浏览器支持。
IE、Firefox 和 Safari 目前完全不支持它们。
我正在使用此代码仅将部分 div 从一个页面导入到其他页面:
<!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>
它在 Chrome 中工作正常,但在 Safari 中不起作用。
错误是:TypeError: undefined is not an object (evaluating 'content.querySelector')
HTML 导入当前 have very limited browser support since they are a very new feature (so new that the specification 仅处于 工作草案 状态)。
它们受 Chrome 36 及大多数其他使用 Blink 浏览器引擎的浏览器支持。
IE、Firefox 和 Safari 目前完全不支持它们。