好消息:现在购买商业模板赠送银牌会员(一元送一天)。同时承接各类网站编辑制作、仿站业务,详情联系右边客服。
织梦仿站、织梦安装、修改、安全处理、疑难解决、PHP网站开发、网页设计、改版、点击这里
DEDE可定制性非常强,我们接到一个项目,要求定制站点的搜索框,要求能有个选项,可以让访客点选使用百度搜索站内内容或者用谷歌搜索站点内容,或者直接搜索整站内容,或者点选按栏目搜索站内内容
全部代码如下:
|
<div class= "search-form" >
|
|
<form role= "search" method= "get" id = "searchform" name=bf onSubmit= "bottomForm();return false;" >
|
|
var $=document.bf.key.value;
|
|
var $2=document.bf.sto.value;
|
|
if (document.bf.sto[0].selected)window. open ( "https://www.baidu.com/s?wd=" + "site%3Abnxb.com+" +$);
|
|
if (document.bf.sto[1].selected)window. open ( "https://www.google.com.hk/search?hl=zh-CN&source=hp&q=" + "site%3Awww.bnxb.com+" +$);
|
|
if (document.bf.sto[2].selected)window. open ( "{dede:global.cfg_basehost/}/app/search.php?kwtype=1&keyword=" +$);
|
|
else window. open ( "{dede:global.cfg_basehost/}/app/search.php?kwtype=1&keyword=" +$+ "&typeid=" +$2);
|
|
<input name= "key" id = "s" class= "s" value= "请输入关键词开始搜索!" onClick= "this.value = '';" style= "background-color: rgb(255, 255, 255); color: rgb(153, 153, 153); opacity: 0.8664601413572597; background-position: initial initial; background-repeat: initial initial; " onKeyPress= "javascript:if(event.keyCode == 13){query(this.value);}" x-webkit-speech= "" type = "text" >
|
|
<SELECT class= "search-select" name= "sto" id = "search-option" >
|
|
<option value= "0" class= "search-select-option" >百度搜索</option>
|
|
<option value= "1111" class= "search-select-option" >谷歌搜索</option>
|
|
<option value= "2222" selected= '1' class= "search-select-option" >全站搜索</option>
|
|
{dede:channelartlist typeid= 'top' }
|
|
{dede: type } <option value= '[field:id/]' >[field:typename/]</option>{/dede: type }
|
|
{dede:channel type = 'son' noself= 'yes' }
|
|
<option value= '[field:id/]' >--[field:typename/]</option>
|
|
<button id = "searchsubmit" class= "btn" >搜索</button>
|
|
<div class= "tagscloud" > <span>快捷搜索:</span> {dede:hotwords num= '5' subday= '30' maxlength= '10' /} </div>
|
|
CSS如下
|
.search- bg {background-color:
|
|
.search- bg .search- open {display:block;}
|
|
.search- bg .inner {overflow:hidden;}
|
|
.search-form,.search-form input {float:left;}
|
|
.search-form .s {background-color:
|
|
.search-form button {border:none; background-color:
|
|
.search-form .search- select {background-color:
|
|
.search-form .search- select -option {background-color:
|
|
其实就是笨牛网的搜索框项目,就是用的这个方法