I found a bug in my code:
This code replaces some regular text with a highlighted version:
var param = getCurrentParam();
var text = document.getElementById("mydiv").innerHTML;
document.getElementById("mydiv").innerHTML = text .replace(param, '<span style="background-color:yellow;">'+param+'</span>');
But this wont work in this case:
param = 'my text more text another line here';
“Real” html:
my text more text
another line here
Because there is a line break (no br, just enter key in the text editor), the param has just white space, but in reality (in the html) the text had something (i guess as such): '\n';
So the replace wont work, because there is probably a: “\n” but it searches instead for a ” “;
How can I fix my replace method?
since line breaks are normally not visible in html, you could just strip them completely