I’m trying to make simple templating for users on a site. I have a test line like this :
<div id="test"><a href="{url}">Test</a></div>
It will alert the HTML properly with the following JS in all browsers except FF:
alert( document.getElementById( 'test' ).innerHTML );
In FF it will change the curly braces to their HTML encoded version. I don’t want to just URL decode in case the user enters HTML with an actual URL instead of one of the templated ones. Any ideas to solve this outside of REGEXing the return value?
My fiddle is here: http://jsfiddle.net/davestein/ppWkT/
EDIT
Since it’s seemingly impossible to avoid the difference in FF, and we’re still early in development, we are just going to switch to using [] instead of {}. Marking @Quentin as the correct answer since it’s what I’m going by,
When you get the
innerHTMLof something, you get a serialised representation of the DOM which will include any error recovery or replacing constructs with equivalents that the browser does.There is no way to get the original source from the DOM.