您的位置:首页 > Web前端 > JavaScript

JavaScript中confirm,alert,prompt的用法及返回值

2011-12-13 11:54 579 查看
window.confirm 参数就只有一个。显示提示框的信息。按确定,返回true;按取消返回false。

<html>

<head>

<script language="javascript">

function k(){

var k=window.confirm('你好!');

alert(k);}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>confirm的属性测试</title>

</head>

<body onLoad="k()">

</body>

</html>
window.alert参数,只有一个,显示警告框的信息;无返回值。

<html>

<head>

<script language="javascript">

function k(){

alert('"你好."')}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>alert的属性测试</title>

</head>

<body onLoad="k()">

</body>

</html>
window.prompt参数,有两个,第一个参数,显示提示输入框的信息。第二个参数,用于显示输入框的默认值。返回,用户输入的值。

<html>

<head>

<script language="javascript">

function k(){

f=window.prompt("你为什么不去死啊?!!!","阿姨其实我也想啊,…………");

alert(f);}

</script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<title>prompt的属性测试</title>

</head>

<body onLoad="k()">

</body>

</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: