Vscode插件
<!DOCTYPE html><html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>往空白窗口输出一个页面</title>
<script type="text/javascript">
window.onload = function(){
var obth = document.getElementById("bth");
obth.onclick = function(){
var opener = window.open();
var strhtml = '<!DOCTYPE html>\
<html>\
<head>\
<title>这是一个新网页</title>\
</head>\
<body>\
<strong>小心偷影子的人,他会偷走你的心</strong>\
</body>\
</html>';
opener.document.write(strhtml);
};
}
</script>
</head>
<body>
<input type="button" name="button" id="bth" value="打开">
</body>
</html>
以上是代码内容,在vscode中使用open with live server显示效果如下:
而在 open in defaul browser显示正常,这是为什么啊。默认浏览器都是Google Chrome