js如何创建和关闭窗口

2025-11-19 08:04:52

1、window.open()方法对应于创建浏览器窗口

第一参数是url是其实讲白了就是网址

第二参数是一个名字你可以自己命名

第三 窗口的属性例如宽度和高度

2、window.close()则是关闭窗口的方法

3、下面代婶腊码你可以用一下试试:

<!DOCTYPE html>

<html>

<head>

  <meta http-equiv="ContentType" content="text/html;charset=utf-8">

  

  </head>

<body>

<!--<input type="button" value="button"/>-->

 肥良粒<h1>Create a new Window</h1>

<hr>

Use the buttons below to test opening

<hr>

<form name="winform">

<input type="button" value="Open New Window" 

onClick="裕王NewWin=window.open('','NewWin','toolbar=no,status=no,width=200,height=100');"/><!--这个按钮是创建一个窗口-->

<input type="button" value="Close New Window" 

onClick="NewWin.close();"/><!--这个按钮创建的·一个窗口被关闭-->

<input type="button" value="Close New Window" 

onClick="window.close();"/><!--这个按钮创建的·一个窗口被关闭-->

</form>

<br>

have Fun

</body>

</html>

4、在这里url你可以输入百度网址试试

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢