相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- ThinkPHP 5.1、6.0、6.1 與 8.0 版本對比分析
- 涉嫌侵權(quán)的人只復(fù)制了版權(quán)軟件,沒有傳播給其他人,是否符合復(fù)制侵權(quán)的判定?
- 網(wǎng)站域名備案到企業(yè)名下后,即表明是商業(yè)使用了嗎?
- 軟件中使用了GPL & MIT 協(xié)議的文件 和 使用了 GPL | MIT 的有什么區(qū)別?
- 網(wǎng)站版權(quán)糾紛中的來源非法是否有嚴(yán)格的司法定義?
- [確定有效] ECSHOP后臺登錄不了的問題解決 https打不開
- 免費搜索代碼:如何利用百度做一個企業(yè)網(wǎng)站內(nèi)搜索? 》
- MySQL 中 HAVING 與 REPLACE 的用法解析
- 深入理解 MySQL 的連接操作:-h、-P、-u、-p 詳解
- 在 MySQL Workbench 中自定義導(dǎo)出文件格式的解決方案
免費搜索代碼:如何利用百度做一個企業(yè)網(wǎng)站內(nèi)搜索?
方法1、直接使用百度的代碼 網(wǎng)址是:http://d.baidu.com/search/freecode.html
注意 百度生成的代碼中,表單是提交到http://www.baidu.com/baidu的,要改為https才行,否則瀏覽器會提示“您即將提交的信息不安全”
方法2、還是使用百度搜索,但是改為自己的代碼
需要實現(xiàn)的效果是,在輸入框為空的時候不可點擊搜索按鈕,輸入框輸入內(nèi)容后,拼接自己網(wǎng)站的網(wǎng)址后,統(tǒng)一提交到百度去搜索。
實際效果見下面網(wǎng)址
https://www.xinhe17.com/ceshiyizhishi/140/1419.html
接下來貼代碼部分
html部分
注意 百度生成的代碼中,表單是提交到http://www.baidu.com/baidu的,要改為https才行,否則瀏覽器會提示“您即將提交的信息不安全”
<form id="search" action="http://www.baidu.com/baidu" target="_blank" οnsubmit="return false;">
<table bgcolor="#FFFFFF">
<input name=tn type=hidden value=baidu>
<input type=text id="search_word" class="search_word" placeholder="請輸入關(guān)鍵詞" name=search_word size=22 onblur="search();">
<input type=hidden id="word" name=word >
<input type="submit" class="ser_but" id="search_but" onsubmit="search();" value="站內(nèi)搜索">
css部分
JS部分 使用jq插件
<script type="text/javascript">
$('#search').on('submit', function(event) {
if(!search()){
// 阻止提交表單
event.preventDefault();
}
});
function search(){
var search_word = $("#search_word").val();
if(search_word !=''){
// 按鈕顏色變化
$("#search_but").removeClass("disable").addClass("able");
$("#search_but").attr('disable',false);//禁用按鈕
// 拼接搜索指令,發(fā)送到百度s
search_word = "site:{$sys.domain} "+search_word;
$("#word").val(search_word);
return true;
}else{
// 清空隱藏域 即提交到百度的指令
$("#word").val('');
// 按鈕顏色變化
$("#search_but").removeClass("able").addClass("disable");
$("#search_but").attr('disable',true);//啟用按鈕
return false;
}
}
上面的{$sys.domain} 替換為您自己的網(wǎng)站域名即可,注意不需要加http://或者h(yuǎn)ttps://