2个回答
展开全部
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Walking in the sunshine </title>
<link type="text/css" rel="stylesheet" href="0309.css" />
<script type="text/javascript" src="/jquery.js" ></script>
</head>
<body >
<div id="container">
<input type="text" id="urlContent" />
<input type="button" value="跳转" onclick="go();" />
</div>
</body>
</html>
<script>
function go()
{
var urlContent = document.getElementById("urlContent").value;
window.location.href = urlContent;
}
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Walking in the sunshine </title>
<link type="text/css" rel="stylesheet" href="0309.css" />
<script type="text/javascript" src="/jquery.js" ></script>
</head>
<body >
<div id="container">
<input type="text" id="urlContent" />
<input type="button" value="跳转" onclick="go();" />
</div>
</body>
</html>
<script>
function go()
{
var urlContent = document.getElementById("urlContent").value;
window.location.href = urlContent;
}
</script>
追问
你好,你写的这个文件如果输入ABC,点按钮后转入ABC,我想让他转入到ABC.HTML 页面,请帮忙再修改下吧,谢谢了
追答
go()方法:window.location.href = urlContent + ".html";
如果按照你的说法,用户输入的内容不一定是正规的网页地址形式,那最好用正则表达式匹配一下,否则容易出问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询