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 8729001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:45:10+00:00 2026-06-13T08:45:10+00:00

So I started out using innerHTML when I wanted to generate a series of

  • 0

So I started out using innerHTML when I wanted to generate a series of divs similar to the following.

<div id="123233"></div>
<div id="123234"></div>
<div id="123235"></div>

Now I have realized that I want to link directly to these divs.

For example: http://www.example.com/page#123234

I have discovered a few scenarios.

  1. If I go directly to http://www.example.com/page#123234 it behaves as if #123234 wasn’t there.
  2. If I first go to http://www.example.com/page and then adds #123234 in the url it works as desired.
  3. If I go http://www.example.com/page#123234 and then write in the same url again it doesn’t work.
  4. If I perform scenario 2 and then reloads the page it stays in the same position.
  5. If I perform scenario 2 and write in the same url again it doesn’t work.

So with this in mind I have my question…

How can I link directly to a div that has been generated by innerHTML?

Additional Information:

I would like the link to work from everywhere. Could be an external domain or just another page like http://www.example.com/startpage.

  • 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-13T08:45:11+00:00Added an answer on June 13, 2026 at 8:45 am

    In your JavaScript, you must be either using some kind of onload or putting all the scripting at the end so that you can use innerHTML. I’ll assume the former. So you have:

    window.onload = function () {
        document.body.innerHTML += "<div id="123233"></div>";
    };
    

    If you add a line to refresh the hash (the bit after the #), then it should scroll to the place you expect:

    window.onload = function () {
        document.body.innerHTML += "<div id=\"123233\"></div>";
        window.location.hash = window.location.hash;
    };
    

    All that is doing is setting the hash to what it is already set to, but the difference being that it is a valid hash when it is set, whereas it isn’t when the page first loads.

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

Sidebar

Related Questions

I just started out using wordpress as a CMS. On the site I have
So I am writing a game in Java, and I started out using the
I started using Core Data for iPhone development. I started out by creating a
Using vi I started editing a html file and I accidentally exited out of
I've just started using GitHub for Windows, and I can't figure out how to
I've started out with a div box that contains a header within it. My
I just started out with Python and wanted to try out tornado. Running the
I just started out using IronRuby (but the behaviour seems consistent when I tested
I started out using asynchronism but to get the returned data became a hassle.
Problem: I just started out in node.js and when using REPL to require a

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.