html怎么写弹出框,html弹出窗口
弹出窗口的html的代码是怎么写的篇1
1、最基本的弹出窗口代码
<SCRIPTLANGUAGE="javascript">
<!--
window.open("page.html")
-->
</SCRIPT>
window.open("page.html")用于控制弹出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(","newwindow","height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")
->
</SCRIPT>
<SCRIPTLANGUAGE="javascript">js脚本开始;window.open弹出新窗口的命令;"page.html"弹出窗口的文件名;"newwindow"弹出窗口的名字(不是文件名),非必须,可用空"代替;
3、用函数控制弹出窗口
<scriptLANGUAGE="JavaScript">
<!--
functionopenwin(){
window.open("page.html","newwindow","height=100,width=400,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")
}
-->
</script>
这里定义了一个函数openwin(),函数内容就是打开一个窗口。
4、同时弹出2个窗口
<scriptLANGUAGE="JavaScript">
<!--
functionopenwin(){
window.open("page.html","newwindow","height=100,width=100,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")
window.open("page2.html","newwindow2","height=100,width=100,top=100,left=100,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no")
}
-->
</script>
为避免弹出的2个窗口覆盖,用top和left控制一下弹出的位置不要相互覆盖即可。
5、主窗口打开文件1.htm,同时弹出小窗口page.html
<scriptlanguage="javascript">
<!--
functionopenwin(){
window.open("page.html","","width=200,height=200")
}
-->
</script>
html中弹出框如何实现的篇2
html中弹出框可以用window.open方法
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<html>
<head>
<scripttype="text/javascript">
functionopen_win()
{
window.open("需要弹5261框的地址")
}
</script>
</head>
<body>
<inputtype=buttonvalue="OpenWindow"onclick="open_win()"/>
</body>
</html>
定义和用法
open()方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。