使用js或者html编写代码,求大神
2013-01-21
<!doctype html>
<html>
<head></head>
<body>
<input type="button" value="Hello" id="btn1" />
<script>
window.onload = function(){
(function(){
var
btn1 = document.getElementById('btn1'), //获取按钮元素
link = function(value){ //生成新页面链接地址
return document.location.href + '?' + value;
},
createLinkNode = function(link){ //创建一个超级链接节点
var
id = 'simulateAClick_012Ase',
e = document.getElementById(id);
if(!e){
e = document.createElement('A');
e.id = id;
e.style.display = 'none';
document.body.appendChild(e);
}
e.href = link;
return e;
},
simulateAClick = function(node){ //模拟点击事件
if (document.createEvent){
var
event = document.createEvent('MouseEvents');
event.initEvent( 'click', true, false );
node.dispatchEvent(event);
}
else if (document.createEventObject){
node.fireEvent('onclick');
}
};
btn1.onclick = function(){ //设置按钮的点击事件
var
_link = link(this.value),
_noteA = createLinkNode(_link);
simulateAClick(_noteA);
};
})();
};
</script>
</body>
</html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>页面跳转</title>
<script>
function openUrl(){
var start=document.getElementById("start").innerHTML;//获取头
var end=document.getElementById("end").innerHTML;//获取尾
var url=document.getElementById("url").value;//获取补充的部分
document.location.href=start+url+end;//跳转页面
}
</script>
</head>
<body>
<span id="start">http://www.</span>
<input type="text" id="url" value="baidu" />
<span id="end">.com</span>
<input type="button" value="打开" onclick="openUrl()" />
</body>
</html>
能不能说的详细点。。。完全是技术小白
<input type="text" id="input1" /><input type="button" onclick="location.href='http://www.baidu.com/s?wd='+document.getElementById('input1').value" value="but" />
把百度改成你自己要的网址