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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T13:14:44+00:00 2026-05-20T13:14:44+00:00

I feel there is such an easy answer to this, but my google-fu is

  • 0

I feel there is such an easy answer to this, but my google-fu is failing me. What I currently have are several links that once clicked, change the HTML content in a DIV.

<a href="#new" onclick="document.getElementById('body').innerHTML
= '<p>NEW</p>';">NEW!</a>

But I want to be able to link to this content. Is there anyway to link to this by going to a URL such as http://www.blahblah.com/index.html#new so it auto-loads the new HTML code?

Forgive me if I’m an idiot… I’m fairly new to javascript.

  • 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-05-20T13:14:44+00:00Added an answer on May 20, 2026 at 1:14 pm

    You can use window.location.hash to see what the hash is on the URL and show the correct DIV based on that. Assuming all your divs are on the page, once you know the div you want to show you would do something like this:

    document.getElementById(idOfDivToShow).style.display='block';
    

    Small example:

    <html>
      <head>
        <script type="text/javascript">
          function loadDiv() {
            if(window.location.hash == '#div1')
              document.getElementById('div1').style.display = "block";
            else if(window.location.hash == '#div2')
              document.getElementById('div2').style.display = "block";
          }
        </script>
      </head>
      <body onload="loadDiv()">
        <div style="display:none" id="div1">div1</div>
        <div style="display:none" id="div2">div2</div>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I feel stupid asking such a simple question, but is there an easy way
I've been thinking of implementing this system, but can't help but feel there's a
I feel like there's a pretty simple way to do this, but I'm not
I feel like there's a simple solution to this, but I'm not really sure
I feel stupid for asking, but there must be a one liner that does
I feel like there's something about grids that I'm missing, but I can't find
Is there an easy way to get the object that created this object. I
In my heart, I feel that there must be a super simple recursive solution
I know there is a question about conditional DetailView, I however feel that's not
I feel like I'm re-inventing the wheel, and that there is a good chance

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.