html点击按钮怎么d出一个浮动的窗体?

html点击按钮怎么d出一个浮动的窗体?,第1张

首先根据需求我们需要一个按钮,一个d出窗口层;\x0d\x0aOK,废话不多说;\x0d\x0a按钮就用一个基本的:\x0d\x0aClick me\x0d\x0a我是浮动的窗口\x0d\x0a\x0d\x0a我们要给浮动层设置一下样式\x0d\x0a.dialog{width:200pxheight:200pxborder:solid 1px #000position:absoluteright:10pxtop:100pxline-height:200pxtext-align:centerdisplay:none}\x0d\x0a\x0d\x0aOK ,下面就是JS部分:\x0d\x0a首先需要引入一个JS库,版本自己定义:\x0d\x0a然后给按钮添加相应的点击事件,让点击button的时候,显示出浮动层\x0d\x0a$(".btn").click(function(){\x0d\x0a$(".dialog").show(100)\x0d\x0a}) 回答于 2022-11-16

html中d出框可以用window.open方法

<html>

<head>

<script type="text/javascript">

function open_win() 

{

window.open("需要d框的地址")

}

</script>

</head>

<body>

<input type=button value="Open Window" onclick="open_win()" />

</body>

</html>

定义和用法

open() 方法用于打开一个新的浏览器窗口或查找一个已命名的窗口。

1、最基本的d出窗口代码

<SCRIPT LANGUAGE="javascript">

<!--

window.open ("page.html")

-- >

</SCRIPT> 

window.open ("page.html") 用于控制d出新的窗口page.html,如果page.html不与主窗口在同一路径下,前面应写明路径,绝对路径(http://)和相对路径(../)均可。

2、经过设置后的d出窗口

<SCRIPT LANGUAGE="javascript">

<!--

window.open ("page.html", "newwindow", "height=100, width=400, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no")&nbsp

->

</SCRIPT>

<SCRIPT LANGUAGE="javascript">js脚本开始;window.open d出新窗口的命令;"page.html" d出窗口的文件名;"newwindow" d出窗口的名字(不是文件名),非必须,可用空"代替;

3、用函数控制d出窗口

<script LANGUAGE="JavaScript">

<!--

function openwin() {

window.open ("page.html", "newwindow", "height=100, width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, status=no")

}

-->

</script>

这里定义了一个函数openwin(),函数内容就是打开一个窗口。

4、同时d出2个窗口

<script LANGUAGE="JavaScript">

<!--

function openwin() {

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")

&nbsp

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>

为避免d出的2个窗口覆盖,用top和left控制一下d出的位置不要相互覆盖即可。

5、主窗口打开文件1.htm,同时d出小窗口page.html

<script language="javascript">

<!--

function openwin() {

window.open("page.html","","width=200,height=200")

}

-->

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7558468.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-07
下一篇 2023-04-07

发表评论

登录后才能评论

评论列表(0条)

保存