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

  • SEARCH
  • Home
  • 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 8880507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:10:43+00:00 2026-06-14T20:10:43+00:00

I need to extract a HTML-Substring with JS which is position dependent. I store

  • 0

I need to extract a HTML-Substring with JS which is position dependent. I store special characters HTML-encoded.

For example:

HTML

<div id="test"><p>l&ouml;sen &amp; gr&uuml;&szlig;en</p></div>​

Text

lösen & grüßen

My problem lies in the JS-part, for example when I try to extract the fragment
lö, which has the HTML-dependent starting position of 3 and the end position of 9 inside the <div> block. JS seems to convert some special characters internally so that the count from 3 to 9 is wrongly interpreted as “lösen ” and not “l&ouml;“. Other special characters like the &amp; are not affected by this.

So my question is, if someone knows why JS is behaving in that way? Characters like &auml; or &ouml; are being converted while characters like &amp; or &nbsp; are plain. Is there any possibility to avoid this conversion?

I’ve set up a fiddle to demonstrate this: JSFiddle

Thanks for any help!

EDIT:

Maybe I’ve explained it a bit confusing, sorry for that. What I want is the HTML:

<p>l&ouml;sen &amp; gr&uuml;&szlig;en</p> .

Every special character should be unconverted, except the HTML-Tags. Like in the HTML above.

But JS converts the &ouml; or &uuml; into ö or ü automatically, what I need to avoid.

  • 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-14T20:10:44+00:00Added an answer on June 14, 2026 at 8:10 pm

    That’s because the browser (and not JavaScript) turns entities that don’t need to be escaped in HTML into their respective Unicode characters (e.g. it skips &amp;, &lt; and &gt;).

    So by the time you inspect .innerHTML, it no longer contains exactly what was in the original page source; you could reverse this process, but it involves the full map of character <-> entity pairs which is just not practical.

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

Sidebar

Related Questions

I need to extract the text between two HTML tags and store it in
I have a html input element from which I need to extract the name
I need to extract the doctype of a HTML page which may be XHTML,
My url on a page is like: http://www.example.com/dir1/file.html?a=1 I need to extract: http://www.example.com how
I need to extract data from HTML-files. The files in question are, most likely,
I need to extract a value from a hidden HTML field, have somewhat figured
I need to extract all the tags from an HTML file, In such a
I have HTML that I need to extract a part number from, the HTML
I have HTML pages as String in Java and I need to extract the
I'm parsing an html document and I need to extract all the prices in

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.