首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

如何写search的函数。比如一个text框,然后onclick直接用百度search

2012-05-15 
怎么写search的函数。比如一个text框,然后onclick直接用百度search如题[解决办法]title无标题文档/title

怎么写search的函数。比如一个text框,然后onclick直接用百度search
如题

[解决办法]
<title>无标题文档</title>
<script type="text/javascript">
function finds(){
var a=document.getElementById("test").value;
window.open("http://www.baidu.com/s?wd="+encodeURIComponent(a));
}
</script>
</head>

<body>
<input type="text" id="test">
<input type="button" onclick="finds()" value="find">
</body>
不知这样行不行 试了几个貌似可以 以前看到过一个例子 忘了放哪了 我给你找找
[解决办法]
getElementsByName("test")[0].value
[解决办法]

探讨

引用:

<title>无标题文档</title>
<script type="text/javascript">
function finds(){
var a=document.getElementById("test").value;
window.open("http://www.baidu.com/s?wd="+encodeURICompo……

热点排行