LOGO OA教程 ERP教程 模切知识交流 PMS教程 CRM教程 开发文档 其他文档  
 
网站管理员

[点晴永久免费OA]纯JS脚本模拟浏览器页面查找并跳转到指定文本内容

admin
2023年4月28日 10:51 本文热度 962
:纯JS脚本模拟浏览器页面查找并跳转到指定文本内容


<style type="text/css">

.result{background:yellow;color:red;font-weight:normal;}

.res{background:yellow;color:red;font-weight:bold;}

</style>

<script type="text/javascript" src="http://www.clicksun.cn/mis/js/jquery-2.1.1.min.js"></script>

<script language="javascript">

var oldKey = "";

var index = -1;

var pos = 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) {                                            //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();

    var regExp = new RegExp(key+'(?!([^<]+)?>)', 'ig');  //正则表达式匹配

    $("td").each(function () {                           //不用.table去遍历这样会导致点击方法失效,直接替换最小单位的td就行

$(this).html($(this).html().replace(regExp, "<span id='result" + index + "' class='result'>" + key + "</span>")); // 高亮操作

    })

    $("#key").val(key);

    oldKey = key;

    $(".result").each(function () {

      if($(this).offset().top == 0){ return; }

    });

    oldCount = $(".result").length;

  }

  $(".result:eq(" + index + ")").addClass("res");              //当前位置关键词改为红色字体

  $(".result:eq(" + index + ")").attr("id", "result" + index); //当前位置强制更改ID,方便定位跳转

window.location.hash="#result" + index;                      //强制跳转到此ID

}


window.onload=function(){

document.getElementById("key").onkeydown=function(event){

if(event.keyCode==13){next();}

}

}

</script>


<input type="text" id="key" placeholder="流程名称关键词" style="width:150px;border-radius:5px;padding-left:6px;height:25px;border:1px #AAAAAA solid;" onchange="next();"/><img src="/mis/images/search_18.gif" style="position:relative;MARGIN-TOP:-3px;MARGIN-LEFT:-22px;MARGIN-right:6px;cursor:pointer;" align="absmiddle" onclick="next();" title="搜索">


该文章在 2023/4/28 10:51:47 编辑过
关键字查询
相关文章
正在查询...
点晴ERP是一款针对中小制造业的专业生产管理软件系统,系统成熟度和易用性得到了国内大量中小企业的青睐。
点晴PMS码头管理系统主要针对港口码头集装箱与散货日常运作、调度、堆场、车队、财务费用、相关报表等业务管理,结合码头的业务特点,围绕调度、堆场作业而开发的。集技术的先进性、管理的有效性于一体,是物流码头及其他港口类企业的高效ERP管理信息系统。
点晴WMS仓储管理系统提供了货物产品管理,销售管理,采购管理,仓储管理,仓库管理,保质期管理,货位管理,库位管理,生产管理,WMS管理系统,标签打印,条形码,二维码管理,批号管理软件。
点晴免费OA是一款软件和通用服务都免费,不限功能、不限时间、不限用户的免费OA协同办公管理系统。
Copyright 2010-2024 ClickSun All Rights Reserved