问题
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