How to add site search function to website using XHTML/HTML? [closed]

可紊 提交于 2019-12-05 02:18:06

问题


I really want to learn how to make my own search engine for my site. I have the defined buttons and labels, but it doesn't search. I can't figure out the HTML or XHTML code for actually searching the site.

This is the code I have so far:

<p class="search">
    <label>SEARCH</label>
    <input name="search" type="text" class="txt" />
    <input name="search-btn" type="submit" class="btn" value="SEARCH" />
</p>

Thanks!


回答1:


You cannot provide a search function with just HTML and XHTML, unless you're just using a standardized form to get some external search engine (like Google) to do the work.

It is possible to do search with JavaScript, but that requires you to transfer all the data to the client, so it is not a very good idea.

If you want to write it yourself, you should use some server-side language, such as PHP or Python - it depends on what you have access to.




回答2:


Check out Google Site Search.




回答3:


There is no feature in HTML that will perform the search. But you do have 3 alternative options:

  1. You can integrate 3rd-party search engines like Google into your site. (Or see one of these examples.)
  2. You can upload a CGI page which uses PHP, Perl, or another scripting language to perform the local search for you.
  3. Lastly, there are some options for JavaScript search engines which work right inside the page.



回答4:


Adding search to your site isn't nearly as simple as creating a search form: it also involves a bunch of programming. Depending on your experience level and what you are trying to do, it can be fun and rewarding to program simple search functionality to your site, but it can also be extremely time-consuming. If you want to take the easy route, use http://www.google.com/sitesearch/ as Jim suggested. If you want to make it yourself, see something like How would I implement a simple site search with php and mySQL? to get started.



来源:https://stackoverflow.com/questions/3016287/how-to-add-site-search-function-to-website-using-xhtml-html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!