JavaScript中confirm,alert,prompt的用法
本文简要介绍JavaScript中confirm,alert,prompt的用法,希望大家学习过程中能得到一些启发。
window.confirm 参数就只有一个。显示提示框的信息。按确定,返回true;按取消返回false。
< SCRIPT> var bln = window.confirm("确定吗?"); alert(bln) < /SCRIPT> window.alert参数,只有一个,显示警告框的信息;无返回值。
< SCRIPT> window.alert("确定。") window.prompt参数,有两个,第一个参数,显示提示输入框的信息。第二个参数,用于显示输入框的默认值。返回,用户输入的值。
< SCRIPT> var str = window.prompt("请输入密码","password") alert(str); < /SCRIPT>
相关文档:
to make a note that I love JavaScript. This article is only meant for some fun, and for us to be aware of some its short-comings.
1. The Name. JavaScript is NOT Java
We'll start with a fun jab at the name choice. While it was originally called Mocha, and then LiveScript, it was later changed to J ......
//创建一个新的元素节点,元素名使用sTagName定义
oElementNode = document.createElementNode(sTagName);
//创建一个新的节点,节点名使用sTextValue定义
oTextNode = document.createTextNode(sTextValue);
//为元素赋一个新的属性,属性名使用sName
oAttribute = document.createAttribute(sName);
//创建一个新的 ......
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>用javascript动态添加删除html元素</title>
<script type="text/javascript"><!--
function $(nodeId) {
re ......
之前看了有关匿名函数的调用,感觉有必要和大家分享一下。
关于什么是匿名函数,及它带来的优势在本文就不深究了,先抛出一个常用的匿名函数:
(function(){alert('yo')})()
很多同学知道怎么用这种匿名函数,却或许并不明白为什么这样写就能够调用匿名函数。也许知道后面的圆括号是执行前面的函数,而并不清楚前面的圆 ......
现在感觉js很好很强大,随着深入的学习,你就会不会拒绝在客户端使用js。之前也在网上找了点资料,一起看看。
value="我是 button" />
动态添加onclick事件:
<input type="button" value="我是 button" id="bu">
<script type="text/javascript">
var bObj=document. ......