为什么名称没有显示在新窗口中?这是一个简单的基于HTML5和JavaScript的疑问。除了在文本框中输入的输入外,所有内容都会显示。
<!DOCTYPE html>
<html>
<body>
<script>
function myFunction() {
var myname = document.myform.name.value;
var myWindow = window.open("", "MsgWindow", "width=200,height=100");
myWindow.document.write("<p>This is 'MsgWindow'. I am 200px wide and 100px tall!</p>");
myWindow.document.write("<p>Name : </p>" + myname);
}
</script>
<p>Click the button to open a new window called "MsgWindow" with some text.
</p>
<form method="POST" name="myform">
<input type="text" name="name">
<button onclick="myFunction()">Try it</button>
</form>
</body>
</html>