Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invisible Delimiter for Strings in HTML

I need a way to identify certain strings in HTML markup. I know what the strings are, but it is possible that they could be substrings of other strings in the document. To find them, I output a special delimiter character (currently using \032). On page load, we go through the HTML and record the location of the strings, and remove the delimiter.

Unfortunately, most browsers show the delimiter character until we can find and remove them all. I'd like to avoid that if possible. Is there a character or string that will be preserved in the HTML content (so a comment wont work) but wont be visible to the user? It also needs to be something that is fairly unlikely to appear next to a string, so something like   wouldn't work either.

EDIT: Sorry, I forgot to mention that the strings will be in attributes, so any sort of tag wont work.

like image 758
noah Avatar asked May 11 '10 16:05

noah


People also ask

How do you add invisible space in HTML?

To insert blank spaces in text in HTML, type   for each space to add. For example, to create five blank spaces between two words, type the   entity five times between the words.

How do you add a secret character?

Invisible character is ALT+255. You need 255 typed on the keypad. Not the one above QWERTY keys. You can use desktop keyboard to do this.


1 Answers

‌ - zero-width non-joiner (see http://htmlhelp.org/reference/html40/entities/special.html)

On the off chance that this already appears in your text, double it up (eg: ‌‌mytext‌‌


Edit in response to comment: works in Firefox 3. Note that you have to search for the Unicode value of the entity.

<html> <body>     <div id="test">         This is a &zwnj;test     </div>      <script type="application/javascript">         var myDiv = document.getElementById("test");         var content = myDiv.innerHTML;         var pos = content.indexOf("\u200C");         alert(pos);     </script> </body> </html> 
like image 181
Anon Avatar answered Sep 23 '22 17:09

Anon