Html 如何让我的搜索栏真正工作?

Html 如何让我的搜索栏真正工作?,html,Html,嘿,伙计们, 我有一个搜索栏,它看起来不错,但我真的不知道如何让它搜索我的整个网站。。。 以下是迄今为止我的html代码: <form class="search2" method="get" action="default.html" /> <input class="search2" type="text" name="serach_bar" size="31" maxlength="255" value="" style="left: 396px; top:

嘿,伙计们, 我有一个搜索栏,它看起来不错,但我真的不知道如何让它搜索我的整个网站。。。 以下是迄今为止我的html代码:

<form class="search2" method="get" action="default.html" />
<input class="search2" type="text" name="serach_bar" size="31" maxlength="255"       
value="" style="left: 396px; top: 153px; width: 293px; height: 26px;" />
<input class="search1" type="submit" name="submition" value="Search" style=" padding-  
bottom:20px; left: 691px; top: 153px; height: 23px" />
<input class="search2" type="hidden" name="sitesearch" value="default.html" />


提前谢谢各位

我知道你说你想跳过谷歌路线,但如果你想在编写自己的代码搜索网站的过程中找到一个临时解决方案,这会有所帮助(我已经详细介绍了Brad Christie在上面的评论中发表的内容):

从上面添加元素ID的HTML:

<form id="frmSearch" class="search2" method="get" action="default.html" />
<input class="search2" id="txtSearch" type="text" name="serach_bar" size="31" maxlength="255"       
value="" style="left: 396px; top: 153px; width: 293px; height: 26px;" />
<input class="search1" type="submit" name="submition" value="Search" style=" padding-  
bottom:20px; left: 691px; top: 153px; height: 23px" />
<input class="search2" type="hidden" name="sitesearch" value="default.html" />

JavaScript:

<script type="text/javascript">
    document.getElementById('frmSearch').onsubmit = function() {
        window.location = 'http://www.google.com/search?q=site:yoursitename.com ' + document.getElementById('txtSearch').value;
        return false;
    }
</script>

document.getElementById('frmSearch')。onsubmit=function(){
window.location=http://www.google.com/search?q=site:yoursitename.com '+document.getElementById('txtSearch').value;
返回false;
}

由于启动搜索的JS不在window.onload函数中,因此需要将脚本块放在表单之后。我试图尽可能地简化它,以帮助您立即将其集成并工作。哦,别忘了将上面JS中的“yoursitename.com”更改为您的实际域名。

您很可能需要一种服务器端语言来处理实际搜索-除非您愿意使用Google Site search<代码>window.location=http://google.com/?q=site:mysite.com+'+escape(document.getElementById('searchbar'))让谷歌来处理,或者去拿SDK,这样你就可以将它集成到你的网站中。我希望我的网站是独立的,所以我想我会把谷歌的网站传给你!我想我需要某种php脚本或其他东西,但我在php方面没有那么先进……你说的interm解决方案是什么意思(对不起,我有点新!)?与此同时,当你建立自己的搜索功能时,需要做一些工作。嗯,它在网络上实际上是不可访问的,但我仍在建立它,我并不着急,所以我想我至少要尝试建立自己的…(但我可能会失败!)啊,我明白了,在这种情况下,这对你没有帮助!哈,如果它真的可以通过网络访问,并且谷歌可以抓取它,这将非常有吸引力。好的,谢谢你的帮助,你知道我可以从哪里开始构建php或其他什么吗??