js 第一篇(常用交互方法)
1. cocument.write("content") //向html 直接写入内容
2. alert("content") // 警告对话框
3. confirm("content") //确认对话框
3. prompt("content") //提问对话框
4. window.open("url","窗体名","窗体打开样式") //窗口打开
四种互动方式汇总实例:
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title> one </title> 5 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 6 <script type="text/javascript"> 7 function opennewwindow(){ 8 var win = confirm("您确认打开新的网站么?"); 9 if (win == true){ 10 var url = prompt("请输入您要打开的网站链接:","https://www.baidu.com/"); 11 if (url != null){ 12 window.open(url,"_pagetest","width=300,height=300,top=20,left=20,menubar=no,toolbar=no"); 13 }else{ 14 alert("您未确认打开指定网站!"); 15 } 16 }else{ 17 alert("您未确认打开!"); 18 } 19 } 20 </script> 21 </head> 22 <body> 23 <input type="button" value="新窗口打开网站" onclick="opennewwindow()" /> 24 </body> 25 </html>
请查看新博客:www.vhosts.cn