<html>
<head>
<script language='javascript'>
//window.confirm('弹出确认提示测试.'); //confirm测试
//document.write('write语句测试.'); //write语句测试
//设置userName的value值
function setUserName()
{
var userName = document.getElementById('userName');
userName.value = "请输入用户名";
}
//转为大定
function setUpperCase()
{
var userName = document.getElementById('userName');
if (userName.value.length != 0)
{
alert(userName.value.toUpperCase());
}
else
{
alert('请在文本中输入内容!');
userName.select();
}
}
//清空userName文本框的内容
function clearTextBox()
{
var userName = document.getElementById('userName');
userName.value = ''
}
//测试userName文本框中输入文字的长度
function alertLength()
{
var userName = document.getElementById('userName');
alert('输入字符的长度为:' + userName.value.length);
}
//弹出一个框口
function openWindow()
{
window.open('Page1.html');
}
//关闭当前框口
function closeWindow()
{
window.close();
}
//设置状态栏的提示文字
function setStatusBar()
{
window.status='用户您好.'
}
//确定测试
function confirmTest()
{
if (confirm('您确实要弹出弹示吗?'))
{
alert('您点击的是确定.');
}
else
{
alert('您点击的是取消.')
}
}
//提示输入框测试
function promptTest()
{
var name = window.prompt('请输入您的姓名:','');
if (name.length != 0)
{
alert('欢迎您 ' + name);
}
}
//判断"同意协议"按钮是否可用
function isAgreeEnable()
{
var chkAgree = document.getElementById('chkAgree');
var btnAgree = document.getElementById('btnAgree');
if (chkAgree.checked)
{
btnAgree.disabled = false;
}
else
{
btnAgree.disabled = true;
}
}
//返回圆周率
function returnPI()
{
alert(Math.PI);
}
//刷新当前页面
function refershPage()
{
window.location.reload();
}
</script>
</head>
<body>请在文本框内输入测试文字:
<input type='input' name='userName'></input><input type='checkbox' name='chkAgree' onclick='isAgreeEnable()'>同意协议</input>
<br/>
<br/>
<input type='submit' name='btnSubmit' value='转为大写' onclick='setUpperCase()' style="width:75px"></input>
<input type='submit' name='btnClear' value='清空' onclick='clearTextBox()' style='width:75px'></input>
<input type='submit' name='btnTestLength' value='测试长度' onclick='alertLength()' style='width:75px'></input>
<input type='submit' name='btnOpenWindow' value='弹出框口' onclick='openWindow()' style='width:75px'></input>
<input type='submit' name='btnCloseWindow' value='关闭框口' onclick='closeWindow()' style='width:75px'></input>
<input type='submit' name='btnSetStatuBar' value='设置状态栏' onclick='setStatusBar()' style='width:75px'></input>
<input type='submit' name='btnConfirmTest' value='确认测试' onclick='confirmTest()' style='width:75px'></input>
<input type='submit' name='btnPromptTest' value='输入提示测试' onclick='promptTest()' style='width:90px'></input>
<input type='submit' name='btnSubmitRegisted' value='提交注册' disabled='false' style='width:75px'></input>
<input type='submit' name='bttReturnPI' value='圆周率' onclick='returnPI()' style='width:75px'></input>
<input type='submit' name='btnRefershPage' value='刷新' onclick='refershPage()' style='width:75px'></input>
</body>
</html>
没有合适的资源?快使用搜索试试~ 我知道了~
JavaScript的基本语法测试.rar
![preview](https://csdnimg.cn/release/downloadcmsfe/public/img/white-bg.ca8570fa.png)
共1个文件
html:1个
![preview-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/scale.ab9e0183.png)
需积分: 0 13 下载量 7 浏览量
2008-10-03
15:19:32
上传
评论
收藏 1KB RAR 举报
温馨提示
JavaScript中的一些基本语法使用示例,示例不是很多,仅供参考。
资源详情
资源评论
资源推荐
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/HTML.png)
共 1 条
- 1
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![js](https://img-home.csdnimg.cn/images/20210720083646.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
icebox126
- 粉丝: 2
- 资源: 2
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)
评论0