window对象 打开与关闭窗口 实例2-01: <html> Head> < title)打开新窗囗</ title〉 <meta charset="UTF-8"> </head> <body> Kimg src="Images/img01 jpg"width="600"height=400"> <script> windowopen(" Demo5-01 html"," new",height=140, width=300, top=100, left=200") </script> K/body> </htm1>
window对象 打开与关闭窗口 实例2-01: <html> <head> <title>打开新窗口</title> <meta charset="UTF-8"> </head> <body> <img src="Images/img01.jpg" width="600" height="400"> <script> window.open("Demo5-01.html","new","height=140,width=300,top=100,left=200"); </script> </body> </html>
window对象 打开与关闭窗口 实例2-02: <body> script> function open i window open("Demo5 01. html",new",toolbar, menubar, scrollbars, status, location, height=200, W idth=200") </script> Form name="form1" method="post action="> < input type=" button"name=" Button" value="创建新窗口 onclick="open Window"> </form> </body)
window对象 打开与关闭窗口 实例2-02: <body> <script> function openWindow(){ window.open("Demo5- 01.html","new","toolbar,menubar,scrollbars,status,location,height=200,w idth=200"); } </script> <form name="form1" method="post" action=""> <input type="button" name="Button" value=" 创 建 新 窗 口 " onclick="openWindow()"> </form> </body>
window对象 打开与关闭窗口 关闭窗口 利用 window对象的 close)方法可以实现关闭当前窗口的功能。 语法: window close 例如2-03:关闭子窗口 <form name="form1" method="post" action=> < input type" button"name=" Button" value="关闭子窗囗" onclick=" newClose0" <script> var win win-window. open (Demo5-01 html,"new,"width=300, height=200) function newCloseo t win. close </script>
window对象 打开与关闭窗口 关闭窗口 利用window对象的close()方法可以实现关闭当前窗口的功能。 语法: window.close() 例如 2-03:关闭子窗口 <form name="form1" method="post" action=""> <input type="button" name="Button" value="关闭子窗口" onclick="newClose()"> </form> <script> var win; win=window.open("Demo5-01.html","new","width=300,height=200"); function newClose(){ win.close(); } </script>
window对象 对话框 浏览器通过 alert0、 confirm0和 prompt0方法可以调用系统对话框向用户显 示消息。 警告框:警告框经常用于确保用户可以得到某些信息。当警告框岀现后,用户 需要点击确定按钮才能继续进行操作。 window. alert方法可以不带上 window对象,直接使用 alert方法
window对象 对话框 浏览器通过alert()、confirm()和prompt()方法可以调用系统对话框向用户显 示消息。 警告框:警告框经常用于确保用户可以得到某些信息。当警告框出现后,用户 需要点击确定按钮才能继续进行操作。 window.alert() 方法可以不带上window对象,直接使用alert()方法
window对象 对话框 实例3: tmI> lead> < title)警告框/ title <meta charset="UTF-8> < script〉 function myFunctiono( alert("你好,我是一个警告框!"); </script> </head> .body> <div)警告框</div < input type=" button" onclick=" my Function0" value="显示警告框”/ </body> </htm1>
window对象 对话框 实例3: <html> <head> <title>警告框</title> <meta charset="UTF-8"> <script> function myFunction(){ alert("你好,我是一个警告框!"); } </script> </head> <body> <div>警告框</div> <input type="button" onclick="myFunction()" value="显示警告框" /> </body> </html>