javaScript 函数
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数调用</title>
<script type="text/javascript">
function aa() //定义函数
{
alert("第一次调用函数。");
}
</script>
</head>
<body>
<form>
<input type="button" value="点击" οnclick=" aa()" />
</form>
</body>
</html>
confirm对话框
当用户点击"确定"按钮时,返回true;点击"取消"时,返回false。
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>confirm</title>
<script type="text/javascript">
function aa(){
var mymessage=true;
while(mymessage){
if(confirm("你是猪吗?"))
{
alert("Oh god, you are a pig!");
var mymessage=false;
}
else
{
alert("Are you sure?")
}
}
}
</script>
</head>
<body>
<input name="button" type="button" onClick="aa()" value="点击我,弹出确认对话框" />
</body>
</html>
prompt对话框
点击确定按钮,文本框中的内容将作为函数返回值,点击取消按钮,将返回null。
打开新窗口
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>window.open</title>
<script type="text/javascript">
function Wopen(){
window.open('http://www.baidu.com','aa','width=800,height=800,menubar=no,toolbar=no, status=no,scrollbars=yes')
}
</script>
</head>
<body>
<input name="button" type="button" onClick="Wopen()" value="点击我,打开新窗口!" / >
</body>
</html>