H50061:html 中引入外部 html 片段
1,只能同域加载
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0"> <title>渲染展示</title> <style></style> <link rel="import" href="temp.html" id="page1"/> </head> <body> <script type="text/javascript"> (function(){ document.write(page1.import.body.innerHTML); })(); </script> </body> </html>
2,
var html = "<!DOCTYPE html>"+
"<html>"+
" <body>"+
" <h1>Hello, world!</h1>"+
" </body>"+
"</html>";
3,
var html = "<!DOCTYPE html>\ <html>\ <body>\ <h1>Hello, world!</h1>\ </body>\ </html>";
document.write(html);
琥珀君的博客