日期:2014-05-16  浏览次数:20428 次

如果写一个JS搜索去变量的
<form action="/search/">
<input class="keyword" name="key" id="key" onblur="soH('key');" onfocus="soT('key');" value=""/>
<button>搜索</button>
</form>

如例我想达到的效果:http://127.0.0.1/search/我想搜索的内容

这样提交时出现了http://127.0.0.1/search/?key=我想搜索的内容

怎么去掉?key=

------解决方案--------------------
<form action="/search/">
<input class="keyword" name="key" id="key" onblur="soH('key');" onfocus="soT('key');" value=""/>
<button  onclick="return doSearch();">搜索</button>
</form>


<script type="text/javascript">
    function doSearch(){
        var a=document.getElementById("key").value;
        window.location.href='/search/'+encodeURIComponent(a);
    }
</script>