.res { color: rgba(255, 0, 0, 1) }
.result { background: rgba(255, 255, 0, 1) }

--- js 部分
var oldKey = "";
var index = -1;
var pos = new Array();//用于记录每个关键词的位置,以方便跳转
var posy = new Array();//用于记录每个关键词的位置,以方便跳转
var oldCount = 0;//记录搜索到的所有关键词总数 function previous(){
index--;
index = index < 0 ? oldCount - 1 : index;
search();
}
function next(){
index++;
//index = index == oldCount ? 0 : index;
if(index==oldCount){
index = 0 ;
}
search();
} function search() {
$(".result").removeClass("res");//去除原本的res样式
var key = $("#key").val(); //取key值
if (!key) {
$(".result").each(function () {//恢复原始数据
$(this).replaceWith($(this).html());
});
oldKey = "";
return; //key为空则退出
}
if (oldKey != key) {
//重置
index = 0;
$(".result").each(function () {
$(this).replaceWith($(this).html());
});
pos = new Array();
posy = new Array();
var regExp = new RegExp(key+'(?!([^<]+)?>)', 'ig');//正则表达式匹配
$("body").html($("body").html().replace(regExp, "<span id='result" + index + "' class='result'>" + key + "</span>")); // 高亮操作
$("#key").val(key);
oldKey = key;
$(".result").each(function () {
pos.push($(this).offset().top);
posy.push($(this).offset().left);
});
oldCount = $(".result").length;
} $(".result:eq(" + index + ")").addClass("res");//当前位置关键词改为红色字体
$("body").scrollTop(pos[index]);//跳转到指定位置
window.scrollTo(0,pos[index]-500);
}

  


---css 部分
.res {
color: Red;
} .result {
background: yellow;
}

--- JSP 部分

<input id="key" type="text"
placeholder="查找姓名、网点"
style="width: 100px; text-align: right; font-size: 14px;" /> <input
type="button" value="下一个" onclick="next()"
style="font-size: 14px;" /> <input type="button" value="上一个"
onclick="previous()" style="font-size: 14px;" />

  

JSP页面 CTRL+F 功能实现的更多相关文章

  1. zf-关于查询机把index.jsp换成index_new.jsp页面之后把功能链接都改成新页面的简单方法

    一开始我都是找action 然后一个一个的改 把onmousedown="goURL('index.jsp')" 改成 onmousedown="goURL('index ...

  2. JSP页面生成验证码功能

    <%@ page language="java" contentType="text/html; charset=UTF-8" import=" ...

  3. myeclipse编辑jsp页面卡

    现象 但是遇到了一种情况,编辑jsp页面卡,尤其是使用快捷键ctrl+ 时会很卡. 编辑java页面没问题的,比较流畅. 在jsp页面中一点ctrl+  就卡几秒钟. 按照上篇文章中优化过后只是编辑j ...

  4. 05传智_jbpm与OA项目_部门模块中增加部门的jsp页面增加一个在线编辑器功能

    这篇文章讲的是在线编辑器功能,之前的部门模块中,增加部门的功能jsp页面起先是这么做的.

  5. UltraEdit (Ctrl + F) 查找、(Ctrl + R)替换功能失效

    环境: Windows 7 Service Pack 1 X64 工具: UltraEdit Version 21 症状: UltraEdit (Ctrl + F) 查找.(Ctrl + R)替换功能 ...

  6. 使Eclipse下支持编写HTML/JS/CSS/JSP页面的自动提示。

    我们平时用eclipse开发jsp页面时智能提示效果不太理想,今天用了两个小时发现了eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用eclip ...

  7. 配置Eclipse编写HTML/JS/CSS/JSP页面的自动提示。

    我们平时用eclipse开发jsp页面时智能提示效果不太理想,今天用了两个小时发现了eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用eclip ...

  8. Web项目中JSP页面的一种调试方法与出现的问题 -- SpringMVC架构测试

    在前端开发中,尤其是MVC架构多人开发,负责前端的童鞋总是需要做静态页面,再和后台连接前无法使用变量如EL表达式等测试功能,所以本人引入了一个模板jsp数据测试专用文件,专门配置所有的变量,然后在待测 ...

  9. 在jsp页面下, 让eclipse完全支持HTML/JS/CSS智能提示(转)

      我们平时用eclipse开发jsp页面时智能提示效果不太理想,今天用了两个小时发现了eclipse也可以像Visual Studio 2008那样完全智能提示HTML/JS/CSS代码,使用ecl ...

随机推荐

  1. CSS基础 定位相关属性的使用方法

    1.相对定位:position:relative: 属性名:position 属性值:relative: 特点:1.相对自己的位置移动 2.配合方位名词移动,如:top.left.right,bott ...

  2. Selenium_浏览器窗口大小(6)

    import time from selenium import webdriver driver = webdriver.Chrome() driver.maximize_window() driv ...

  3. spring boot 单元测试 --- 在测试类使用 javabean注解操作接口

    1.依赖包 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>s ...

  4. ES6常用知识点

    一.变量 var:定义的变量有时候会成为全局变量 let:定义的变量严格,只在代码块内有效 const:声明的变量是常量,不能被修改 二.数据类型 字符串 @定义:~字符串定义标记,支持换行.  #常 ...

  5. 【Java常用类】Calendar

    Calendar日历类 实例化 方法一 创建其子类**(GregorianCalendar)**的对象 方法二 调用其静态方法getInstance() Calendar instance = Cal ...

  6. 【刷题-LeetCode】200 Number of Islands

    Number of Islands Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. ...

  7. 【记录一个问题】thanos receiver在更换tsdb文件后,内存并未显著下降

    在16:14,切换了TSDB 在16::15分切换了TSDB,并且上游未写入数据 容器的内存并未在这个时刻明显下降 疑惑: 如果thanos receiver的内存占用不与time series数量正 ...

  8. 微信小程序-国际化(miniprogram-i18n)

    前情提要 最近维护了一个微信小程序的老项目,维护的其中一项是添加国际化.由于踩了蛮多坑,所以就有了这篇文档!!! miniprogram-i18n 对除小程序外的其他框架开发做过国际化的朋友来说i18 ...

  9. vue学习8-for循环

    <!DOCTYPE html> <html lang='en'> <head>  <meta charset='UTF-8'>  <meta ht ...

  10. element 日期时间选择器type = "datetimerange",限制时间的选择范围

    这里限制了只能选择一周的时间   pickerOptions:{          onPick(time){              // 如果选择了只选择了一个时间              i ...