
HTML代码 文本框、按钮 文本框中输入“123”点击按钮转入1.html 文本框内容是其他字符,转入2.html
HTML代码文本框、按钮文本框中输入“123”点击按钮转入1.html文本框内容是其他字符,转入2.html...
HTML代码 文本框、按钮 文本框中输入“123”点击按钮 转入1.html
文本框内容是其他字符,转入2.html 展开
文本框内容是其他字符,转入2.html 展开
展开全部
<html>
<head>
<title>无标题页</title>
<script type="text/javascript">
function btnclick() {
var textValue = document.getElementById("text").value;
if (textValue = "123") {
document.location = "1.html";
}
else {
document.location = "2.html";
}
}
</script>
</head>
<body>
<input type="text" id="text" /><input type="button" value="点击" id="btn" onclick="btnclick()" />
</body>
</html>
注释:上面就是实现的方法,1.html和2.html你可以自己写内容然后更改JS里面的那个地址就可以,这里只给你写怎么验证和跳转。希望采纳。
<head>
<title>无标题页</title>
<script type="text/javascript">
function btnclick() {
var textValue = document.getElementById("text").value;
if (textValue = "123") {
document.location = "1.html";
}
else {
document.location = "2.html";
}
}
</script>
</head>
<body>
<input type="text" id="text" /><input type="button" value="点击" id="btn" onclick="btnclick()" />
</body>
</html>
注释:上面就是实现的方法,1.html和2.html你可以自己写内容然后更改JS里面的那个地址就可以,这里只给你写怎么验证和跳转。希望采纳。
追问
不输入 123 也会跳转到1.html
追答
就是啊,你不是就是要求输入123跳转到1.html,什么也不输入则跳转到2.html吗? 你想排除字符串的话,可以在修改成
function btnclick() {
var textValue = document.getElementById("text").value;
if (textValue = "123") {
document.location = "1.html";
}
else if(textValue !="123" && textValue!="") {
document.location = "2.html";
}
}
这样既可。
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>跳转网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript">
function leave() {
if (document.getElementsByName('wenben')[0].value=='123') {
window.location.href="1.html";
} else {
window.location.href="2.html";
}
}
</script>
<style type="text/css">
</style>
</head>
<body>
<p><textarea name="wenben"></textarea></p>
<p><input type="button" value="测试" onclick="leave();"></p>
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<head>
<title>跳转网页</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="description" content="" />
<meta name="keywords" content="" />
<script type="text/javascript">
function leave() {
if (document.getElementsByName('wenben')[0].value=='123') {
window.location.href="1.html";
} else {
window.location.href="2.html";
}
}
</script>
<style type="text/css">
</style>
</head>
<body>
<p><textarea name="wenben"></textarea></p>
<p><input type="button" value="测试" onclick="leave();"></p>
</body>
</html>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询