I'm quite new to JavaScript and HTML. I'm trying to write a program that takes in a number and spits out garbled text (containing all sorts of special characters and symbols; here's a sample: @;f%UA@;f%UDaVI*&e"q+/[)).
My JavaScript code takes in an input number and generates a string of garbled characters, which is then displayed on a paragraph on the page (using document.getElementById("output").innerHTML) and simultaneously copied to clipboard. The program seems to work as intended for the most part, but whenever the garbled output string contains a left angular bracket (<), the text in the paragraph is not displayed completely.
Here's a sample output:
- Garbled string:
K@8K@<vI,= ]1h<r50\ ` - Output in the page body:
K@8K@
Even the above code formatting is broken at the left angular bracket <, which leads me to suspect that this may be caused by an escape sequence or something similar. I'd be very glad if someone can suggest a way to fix this issue with the text rendering.
<and>simply have in HTML. You don’t want what you created interpreted as HTML, you want it treated as text - so don’t use.innerHTML, use.innerTextinstead.