Mark.js keep marking permanently?

喜欢而已 提交于 2019-12-24 19:18:27

问题


i am currently using mark.js for a google chrome extension to highlight some text on a web page.

Now whenever i refresh the page or do a right click all my marking is lost.

Is there a way to keep that marking? As far as i see mark.js does not change the DOM. I would like to mark the text but also be able e.g. when i print that page or save it as a pdf, to maintain the highlighting i did..

That is the way i mark. it is pretty much the same as instructed on https://markjs.io/:

function mark(text, label){
var paragraphs = Array.from(document.getElementsByClassName('description-line'));
switch(label){
        case "strAdv":
            for(var elem of paragraphs) { // loop through each element in paragraphs array
                 var instance=new Mark(elem);
                 instance.mark(text, {className: "strAdv",separateWordSearch:false});

             }
             break;
....

strAdv.css:

/*CSS to define diferent marking classes*/
.strAdv {
padding: 0;
background-color: chartreuse;
}

来源:https://stackoverflow.com/questions/59395471/mark-js-keep-marking-permanently

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