如何给html文件做搜索

来源:百度知道 编辑:UC知道 时间:2024/05/22 01:08:01
我正在做软件写说明,都是html格式的。大概有50个主题。这50个主题的文件将随着软件程序一起安装在用户的电脑上。我想给这些主题做一个搜索页面,用户在这个页面的搜索文本框中输入一些文字,然后点击“那个网页上的搜索按钮。就可以把含有这个搜索文字的html主题给罗列出来,并加上链接。

因为是直接安装在用户的机器上,所以不可能使用数据库等方法。(同时也不需要编译成chm格式的文件)。只能通过原始的搜索代码实现站内搜索。请问应该如何实现搜索主题的功能。

虽然没分,还是把我从别处抄来的代码转给你吧:

<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>test</title>
</head>
<body style="font-size: 10pt">
<script language="JavaScript">
var NS4 = (document.layers); // Which browser?
var IE4 = (document.all);
var win = window; // window to search.
var n = 0;
function findInPage(str) {
var txt, i, found;
if (str == "")
return false;
// Find next occurance of the given string on the page, wrap around to the
// start of the page if necessary.
if (NS4) {
// Look for match starting at the current point. If not found, rewind
// back to the first match.
if (!win.find(str))
while(win.find(str, false, true))
n++; <