20151114

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="application/javascript">
function quer()
{
    if(confirm('确实要删除?'))
    {
        alert('删除成功')
    }
    else
    {
        alert('删除失败')
    }
}

function tishi()
{
    prompt("请输入代码!","123");
}

</script>
</head>

<body>

<input type="button" value="关闭对话框中
" onclick="quer();">

<input type="button" value="提示对话框中" onclick="tishi();">
</body>
</html>
确认命令窗口
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<script type="application/javascript">

function deit()
{
    var te = document.getElementById("text1");
    
    te.value = "新的123值";
    
}

function editByName()
{
    try{
    var te = document.getElementsByName("text2");
    for(i=0;i<te.lenth;i++)
    {
        te[i].value = "新的值"+i;
        
        }
}
catch(ex)
{
    alert(ex.message)
    
    }

}
</script>
</head>
<body>
<input id="text1" name="text2" type="text" value="默认" width="30"/>
<input type="button" name="text2" value="修改" onclick="edit();">
<input type="button" name="text2" value="修改ByName" onclick="editByName();">
</body>
</html>
获取文档中的指定元素
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script type="application/javascript">
//延时执行代码:
//setTimeout("window.location='http://www.baidu.com'",3000);
//周期执行代码
//setInterval("alert('周期执行')",2000)
//网页浏览历史
//window.history.go(-1);


function jianc()
{
    var t = document.getElementById("tid1");
    //var t = form1.tid1;
    
    if(t.value == "")
    {
        alert("请填写用户代码!");
        
        return false;
    }
    var p = document.getElementsByName("tname2");
    //var p = form1.tid2;
    var a = p[0];
    
    if(a.value == "")
    {
        alert("请填写用户密码!");
        
        return false;
        
    }
    return true;
}


</script>
</head>

<body>

<form id="form1" name="form2" method="get" onsubmit="return jianc();">

用户代码<input id="tid1" name="tname1" value="" type="text" width="30"/>

<br /><br />

用户密码<input id="tid2" name="tname2" type="password" width="30"/>

<br /><br />

<input type="submit" value="登录"/>

<br />

</form>

跳转:
<input type="submit" value="跳转" onclick="window.location='http://www.baidu.com'">
1
<input type="submit" value="后退到上一网页" onclick="window.history.go(-1);">
2
<input type="submit" value="前进到上一网页" onclick="window.history.go(1);">




</body>
</html>
登陆、跳转、前进、后退
原文地址:https://www.cnblogs.com/name-hanlin/p/4965020.html