Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9181725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:23:15+00:00 2026-06-17T18:23:15+00:00

Say I’ve got this HTML page: <html> <head> <script type=text/javascript> function echoValue(){ var e

  • 0

Say I’ve got this HTML page:

<html>
  <head>
    <script type="text/javascript">
      function echoValue(){
        var e = document.getElementById("/path/&#x24;whatever");
        if(e) {
          alert(e.innerHTML);
        }
        else {
          alert("not found\n");
        }
      }
    </script>
  </head>
  <body>
    <p id="/path/&#x24;whatever">The Value</p>
    <button onclick="echoValue()">Tell me</button>
  </body>
</html>

I would assume that the browser treats the ID-string /path/&#x24;whatever as simple string. Actually, it converts the &#x24; to it’s rendered representation ($).

The javascript code however uses the literal string &#x24; to search for the element. So, the call document.getElementById 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 $. But the web page gets generated and the generator does the escaping. So, I have to cope with what I’ve got.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:23:16+00:00Added an answer on June 17, 2026 at 6:23 pm

    In the <p id="...">, the &#x24; sequence is interpreted as $, because it appears in an attribute and is treated as an HTML entity. Same goes for all other element attributes.

    In the <script> element, HTML entities are not interpreted at all, so it shows up literally.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have this anonymous function: (function(window){ var private = 'private msg'; function sayit()
Say you in JavaScript are handed a single DOM element or Document (for example
Say I have this function (assume I'm accessing Cache in a threadsafe way): object
Say I got this C++ code: class class1{ class2 *x; } class class2{ class1
Say that I have this markup excerpt: <p onblur=...>text 1</p> <p class=myclass>text 2</p> <p
Say I have this little bit of code: public static void LoadSomething(Type t) {
Say I include a script at the top of an html body that doesn't
Say I have a SSI script that uses exec, or a PHP script that
Say I have this: private list<myClass> myCollection; Is there a programming idiom to shorten
Say we have this block: int (^aBlock)(BOOL) = ^(BOOL param) { ... My current

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.