Why does the browser modify the ID of an HTML element that contains &#x?

bigbob87

New Member
Say I've got this HTML page:\[code\]<html> <head> <script type="text/javascript"> function echoValue(){ var e = document.getElementById("/path/$whatever"); if(e) { alert(e.innerHTML); } else { alert("not found\n"); } } </script> </head> <body> <p id="/path/$whatever">The Value</p> <button onclick="echoValue()">Tell me</button> </body></html>\[/code\]I would assume that the browser treats the ID-string \[code\]/path/$whatever\[/code\] as simple string. Actually, it converts the \[code\]$\[/code\] to it's rendered representation (\[code\]$\[/code\]).The javascript code however uses the literal string \[code\]$\[/code\] to search for the element. So, the call \[code\]document.getElementById\[/code\] fails and I never get hands on the value of the paragraph.Is there a way to force the browser into using the given ID string literally?Edit:
Of course I know that I don't have to escape the \[code\]$\[/code\]. But the web page gets generated and the generator does the escaping. So, I have to cope with what I've got.
 
Back
Top