【发布时间】:2014-02-04 10:04:38
【问题描述】:
我正在做一个关于个性化网络搜索的项目。 我创建了一个离线站点,它从我的站点中搜索文档,并使用 PHP 和 JavaScript 来构建它。 我想根据关键字而不是文档搜索执行简单搜索,我需要在以下 java 脚本中更改以根据我的站点中的关键字执行基本搜索。
下面使用java脚本搜索的代码sn-p如下,
$(document).ready(function(){
/* initialize the data "filetype" */
$("#types a:first").click();
$("#types a").click(
function () {
$("#types a").each(
function(){
$(this).css({ "background-color":"", "padding" : "", "color": "#6599CB",fontWeight:"normal"});
}
);
$(this).css({ "background-color":"#6599CB", "padding" : "5px", "color":"white", fontWeight:"bolder"});
return false;
});
function updateLink() {
$("#google").attr("href", "http://www.google.com/search?q=" + encodeURI($("#word").val()) + "+filetype%3A" + encodeURI($("#types").data("filetype")));
}
enter code here
$("#types a").click( function () {
$("#types a").each(
function(){
$(this).css({ "background-color":"", "padding" : "", "color":"#6599CB", `enter code here`fontWeight:"normal"});
}
);
$(this).css({ "background-color":"#6599CB", "padding" : "5px", "color":"white", fontWeight:"bolder"});
$("#types").data("filetype", $(this).attr("value"));
updateLink();
$("#word").focus();
return false;
});
/* update the link when "#word" changes */
$("#word").keydown(function(e){
updateLink();
}).keyup(function(e){
/* submit search with "enter" key */
if(e.keyCode == '13') enter code here{
$("#google").click();
}
});
});
这是一个 java 脚本代码,搜索基于文档类型,如 Doc、pdf 等 但是如果我想根据关键字执行简单的搜索,那么我需要在这个java脚本中做些什么改变,请朋友们帮我解决这个问题。
【问题讨论】:
标签: javascript php search web