DEDE可定制性非常强,接到一个项目,要求定制站点的搜索框,要求能有个选项,可以让访客点选使用百度搜索站内内容或者用谷歌搜索站点内容,或者直接搜索整站内容,或者点选按栏目搜索站内内容
全部代码如下:
function bottomForm(){ 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);return false} 百度搜索 谷歌搜索 全站搜索{dede:channelartlist typeid='top' }{dede:type} [field:typename/]{/dede:type}{dede:channel type='son' noself='yes'}--[field:typename/]{/dede:channel}{/dede:channelartlist}快捷搜索: {dede:hotwords num='5' subday='30' maxlength='10'/}CSS如下
/*search-bg*/.search-bg {background-color:#F5F5F5; width:100%; padding:20px 0; display:none;}.search-bg.search-open {display:block;}.search-bg .inner {overflow:hidden;}.search-form,.search-form input {float:left;}.search-form .s {background-color:#fff; border:1px solid #ddd; height:22px; line-height:22px; padding:5px; font-size:0.875em; width:500px; border-radius:3px;}.search-form button {border:none; background-color:#1e82aa; color:#fff; height:32px; padding:0 10px; cursor:pointer; margin:1px 0px; border-radius:6px; font-size:1em;}.search-form .search-select {background-color:#fff; border:1px solid #ddd; height:34px; line-height:34px; margin:1px 5px;}.search-form .search-select-option {background-color:#E9EAEC;font-weight:bold}其实就是笨牛网的搜索框项目,就是用的这个方法