Home  >  Article  >  Web Front-end  >  js确认框confirm()三种使用方法

js确认框confirm()三种使用方法

WBOY
WBOYOriginal
2016-06-01 09:54:411730browse

先为大家介绍javascript确认框的三种使用方法,具体内容如下

第一种方法:挺好用的,确认以后才能打开下载地址页面。原理也比较清晰。主要用于删除单条信息确认。

<code class="language-javascript"><script language="javascript"> 
function del() { 
 var msg = "您真的确定要删除吗?\n\n请确认!"; 
 if (confirm(msg)==true){ 
  return true; 
 }else{ 
  return false; 
 } 
} 
</script> </code>

调用方法:

<code class="language-html"><a href="del.php?id=123" onclick="javascript:return del()">删 除</a> </code>

 

第二种方法:原理跟上面的一样。JavaScript删除确认框 

<code class="language-html"><a href="javascript:if(confirm('%E7%A1%AE%E5%AE%9E%E8%A6%81%E5%88%A0%E9%99%A4%E5%90%97?'))location='manongjc.com'">删除</a>
</code>

 

第三种方法:主要用于批量删除的确认提示 

<code class="language-html"><input name="Submit" type="submit" class="inputedit" value="删除" onclick="{if(confirm('确定纪录吗?')){
  this.document.formname.submit();
  return true;}return false;
 }"> 
<input name="按钮" type="button" id="ok" onclick="{if(confirm('确定删除吗?')){
 window.location='Action.asp?Action=Del&
 TableName=Item&
 ID=<%=ID%>';
 return true;
}return false;}" value="删除栏目">
</code>

 

再为大家分享一个实例:js的确认框confirm()代码实例

confirm()确认框在网页中比较常用,当然有些美观度要求比较高的网页可能需要自定义这样的功能,下面就来介绍一下window对象的confirm()函数的用法,下面县看一段代码实例,因为没有什么再比这个更直观了。

<code class="language-html"> 
 
 
<meta charset="gb2312"> 
<title>confirm()浠g</title></code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn