JS中confirm,alert,prompt函数
2009-03-25 19:58
357 查看
window.alert:参数,只有一个,显示警告框的信息;
无返回值.
<script>
window.alert("确定.")
</script>
window.confirm : 参数就只有一个.显示提示框的信息.
按确定,返回true; 按取消返回false.
<script>
var bln = window.confirm("确定吗?");
alert(bln)
</script>
window.prompt:参数,有两个,
第一个参数,显示提示输入框的信息.
第二个参数,用于显示输入框的默认值.
返回,用户输入的值.
<script>
var str = window.prompt("请输入密码","password")
alert(str);
</script>
今天上午有一个面题目,是JS写函数。根据填写的年龄,判断是否正确,如果正确就页面就指向WebForm1.aspx,如果不正确就把指针停留在ttt上。
年龄:<input name="ttt" type="text" value="5" />
<button id="button1" onclick ="javascript:onsureForm()"></button>
</div>
</form>
<script type="text/javascript" >
function onsureForm(){
var age = document.getElementsByName("ttt")[0].value;
if(confirm("area you sure your age is " + age )){
window.location="WebForm1.aspx";
}else{
document.getElementsByName("ttt")[0].focus();
}
}
</script>
无返回值.
<script>
window.alert("确定.")
</script>
window.confirm : 参数就只有一个.显示提示框的信息.
按确定,返回true; 按取消返回false.
<script>
var bln = window.confirm("确定吗?");
alert(bln)
</script>
window.prompt:参数,有两个,
第一个参数,显示提示输入框的信息.
第二个参数,用于显示输入框的默认值.
返回,用户输入的值.
<script>
var str = window.prompt("请输入密码","password")
alert(str);
</script>
今天上午有一个面题目,是JS写函数。根据填写的年龄,判断是否正确,如果正确就页面就指向WebForm1.aspx,如果不正确就把指针停留在ttt上。
年龄:<input name="ttt" type="text" value="5" />
<button id="button1" onclick ="javascript:onsureForm()"></button>
</div>
</form>
<script type="text/javascript" >
function onsureForm(){
var age = document.getElementsByName("ttt")[0].value;
if(confirm("area you sure your age is " + age )){
window.location="WebForm1.aspx";
}else{
document.getElementsByName("ttt")[0].focus();
}
}
</script>
相关文章推荐
- 如何设置WebView支持js的Alert,Confirm,Prompt函数的弹出提示框.
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- android studio 将HTML5封装成APK && 设置WebView支持js的Alert,Confirm,Prompt函数的弹出提示框.
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- JS中confirm,alert,prompt函数
- js 重写 bootstrap 样式 alert/confirm 消息窗口 - cnhxz
- JS:1.1 消息框(alert,confirm,prompt)
- js中alert()|confirm()|prompt()的用法
- js中confirm()与alert()方法用法与区别
- 【JS】alert()、confirm()、prompt()的区别
- 在Android的webview中定制js的alert,confirm和prompt对话框的方法
- JS对话框函数alert(),confirm(),prompt()
- (转)在Android的webview中定制js的alert,confirm和prompt对话框的方法
- js中的alert,confirm,prompt,遗忘的角落
- iOS用WKWebView与JS交互获取系统图片及WKWebView的Alert,Confirm,TextInput的监听代理方法使用,屏蔽WebView的可选菜单
- JS alert()、confirm()、prompt()的区别
- iOS用WKWebView与JS交互获取系统图片及WKWebView的Alert,Confirm,TextInput的监听代理方法使用,屏蔽WebView的可选菜单