html中点击click事件后的提示框内容

html中点击click事件后的提示框内容,第1张

JavaScript 有三种类型的d出框:警告框、确认框和提示框。

alert 警告框

如果要确保信息传递给用户,通常会使用警告框。当警告框d出时,用户将需要单击“确定”来继续。

事例   alert("我是一个警告框!")    

引号内的部分替换成自己的内容即可。

confirm 确认框

如果您希望用户验证或接受某个东西,则通常使用“确认”框。当确认框d出时,用户将不得不单击“确定”或“取消”来继续进行。如果用户单击“确定”,该框返回 true。如果用户单击“取消”,该框返回 false。

例如

var r = confirm("请按按钮")      //引号内的部分替换成自己的内容即可。

if (r == true) {

x = "您按了确认!"

} else {

x = "您按了取消!"

}

prompt 提示框

如果您希望用户在进入页面前输入值,通常会使用提示框。当提示框d出时,用户将不得不输入值后单击“确定”或点击“取消”来继续进行。如果用户单击“确定”,该框返回输入值。如果用户单击“取消”,该框返回 NULL。

例如

var person = prompt("请输入您的姓名", "比尔盖茨")

if (person != null) {

document.getElementById("demo").innerHTML = "你好 " + person

}

确定使用的语言,记录点击次数应该是需要脚本语言,JS 或者jquery;

记录点击次数变量(需要在脚本语言中定义);

确保页面不会刷新,因为刷新后会清空统计数据;

然后根据变量每点击一次+1;

根据变量的数值进行提示;

以上是编程思路,定义全局变量,定义JS点击方法,点击+1,判断是否等于某一次数进行提示;

html做点一个按钮就d出文字的代码:

最基本的d出窗口代码

<SCRIPT LANGUAGE="javascript">

<!-- window.open ('page.html') --></SCRIPT>

经过设置后的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=n o, status=no') //-->

</SCRIPT>

用函数控制d出窗口

<html>

<head>

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

</head>

<body onload="openwin()">

</body>

</html>

同时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=n o, status=no")//window.open ("page2.html", "newwindow2", "height=100, width=100, top=1 00, left=100,toolbar=no, menubar=no, scrollbars=no, resizable=no, loca tion=no, status=no")//} //-->

</script>

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

如下代码加入主窗口<head>区:

<script language="javascript">

<!-- function openwin() { window.open("page.html","","width=200,height=200") } //-->

</script>

加入<body>区: <a href="1.htm" onclick="openwin()">open</a>

d出的窗口之定时关闭控制

首先,将如下代码加入page.html文件的<head>区:

<script language="JavaScript">

function closeit()

{ setTimeout("self.close()",10000) //毫秒 }

</script>

在d出窗口中加上一个关闭按钮

<FORM>

<INPUT TYPE='BUTTON' VALUE='关闭' onClick='window.close()'>

</FORM>

内包含的d出窗口-一个页面两个窗口

<html>

<head>

<SCRIPT LANGUAGE="JavaScript">

function openwin()

{ OpenWindow=window.open("", "newwin", "height=250, width=250,toolbar=no,scrollbars="+scroll+",menubar=no")

//OpenWindow.document.write("<TITLE>例子</TITLE>")

OpenWindow.document.write("<BODY BGCOLOR=#ffffff>")

OpenWindow.document.write("<h1>Hello!</h1>")

OpenWindow.document.write("New window opened!")

OpenWindow.document.write("</BODY>")

OpenWindow.document.write("</HTML>")

OpenWindow.document.close() }

</SCRIPT>

</head>

<body>

<a href="#" onclick="openwin()">打开一个窗口</a>

<input type="button" onclick="openwin()" value="打开窗口">

</body>

</html>

终极应用--d出的窗口之Cookie控制

首先,将如下代码加入主页面HTML的<HEAD>区:

<script>

function openwin(){

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

function get_cookie(Name) { var search = Name + "=" var returnvalue = ""

if (document.cookie.length >0) { offset = document.cookie.indexOf(search)

if (offset != -1) { offset += search.length end = document.cookie.indexOf("", offset)

if (end == -1)

end = document.cookie.length

returnvalue=unescape(document.cookie.substring(offset, end)) } }

return returnvalue}

function loadpopup(){ if (get_cookie('popped')==''){ openwin()

document.cookie="popped=yes" } }

</script>

Asp教程-ASP应用

this.Response.Write(<Script>window.open('WebForm7.aspx','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=750,height=470,left=80,top=40')</script>")

d出跟你当前的窗口有没有菜单工具栏没有关系,你只要在页面中写一个脚本它就d出了.比如

<a href=# onclick="window.open('xxx.aspx','窗口名称','参数')">xxxxx</a>

以下列出一些d出窗口的参数:

(如:"fullscreen=yes, toolbar=yes")。下面是被支持的各种特性。

channelmode = { yes | no | 1 | 0 } 是否在窗口中显示阶梯模式。默认为no。

directories = { yes | no | 1 | 0 } 是否在窗口中显示各种按钮。默认为yes。

fullscreen = { yes | no | 1 | 0 } 是否用全屏方式显示浏览器。默认为no。

height = number 指定窗口的高度,单位是像素。最小值是100。

left = number 指定窗口距左边框的距离,单位是像素。值必须大于或者等于0。

location = { yes | no | 1 | 0 } 指定是否在窗口中显示地址栏。默认为yes。

menubar = { yes | no | 1 | 0 } 指定是否在窗口中显示菜单栏。默认为yes。

resizable = { yes | no | 1 | 0 } 指定是否在窗口中显示可供用户调整大小的句柄。默认为yes。

scrollbars = { yes | no | 1 | 0 } 指定是否在窗口中显示横向或者纵向滚动条。默认为yes。

status = { yes | no | 1 | 0 } 指定是否在窗口中显示状态栏。默认为yes。

titlebar = { yes | no | 1 | 0 } 指定是否在窗口中显示标题栏。在非调用HTML Application或者一个对话框的情况下,这一项将被忽略。默认为yes。

toolbar = { yes | no | 1 | 0 } 指定是否在窗口中显示工具栏,包括如前进、后退、停止等按钮。默认为yes。

top = number 指定窗口顶部的位置,单位是像素。值必须大于或者等于0。

width = number 指定窗口的宽度,单位是像素。最小值是100。


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

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

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

发表评论

登录后才能评论

评论列表(0条)

保存