自定义搜索格式 伪静态修改专用JS

网站建设小技巧 2019-10-22 11:14:24 评论

搜索格式为 /ss-关键词 ,可自定义修改

分别是

JS

CSS

HTML

一气呵成

<script>
    function goSearchKeyPress() {
        if (event.keyCode == 13) {
            goSearch();
        }
    }

    function goSearch() {
        var kw = document.getElementById('t_keywords');
        var search_a = document.getElementById('search_a');
        if (kw == null || kw.value == '') {
            return;
        }
        var url = "/ss-" + encodeURI(kw.value);
        search_a.href = url;
        search_a.click();
    }
</script>
<style>
/* 搜索 */
.tuku_search {
    float: right;
    width: 300px;
    height: 30px;
    overflow: hidden;
    margin-right:0px;
}
.tuku_search span {
    float: left;
}
.tuku_search span input {
    width: 220px;
    height: 26px;
    border: 1px solid #bbb;
    line-height: 26px;
	padding-left: 10px;
}
.tuku_search a {
    width: 57px;
    height: 27px;
    line-height: 27px;
    text-align: center;
    color: #fff;
    float: right;
    background-color: #666;
}
.tuku_search a:hover {
    color: #fff;
    text-decoration: none;
}
</style>

            <div class="tuku_search">
                <span>
                    <input type="text" id="t_keywords" name="t_keywords" value="" onkeypress="goSearchKeyPress();">
                </span>
                <a style="display: none" href="" id="search_a" name="search_a" target="_blank"></a>
                <a onclick="goSearch();" href="javascript:void;">搜索</a>
            </div>

        </div>
</div>
上一篇:PHP数组清除空组方法
下一篇:没有了

本文来自:淮安SEO

链接网址:https://www.huaianseo.cn/jiqiao/76.html

评论

说点什么吧
  • 全部评论(0
    还没有评论,快来抢沙发吧!