如何打开新窗口

时间:2019-05-14 23:00:23

标签: javascript window jsfiddle stackexchange

嵌入式代码段只能在jsfiddle上使用,而不能在stackoverflow上使用,为什么?

另外,如果我删除脚本并将其放在jsfiddle上的javascript区域中,它也将不起作用,为什么?

<!DOCTYPE html>
<html>
<body>

<p>Click the button to open a new window called "MsgWindow" with some text.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
  var myWindow = window.open("", "MsgWindow", "width=200,height=100");
  myWindow.document.write("<p>This is 'MsgWindow'. I am e and 100px tall!</p>");
}
</script>

</body>
</html>

0 个答案:

没有答案