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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:16:24+00:00 2026-06-07T04:16:24+00:00

I have looked and looked for an answer to this question. So I apologize

  • 0

I have looked and looked for an answer to this question. So I apologize in advance when the solution is very easy.

I want to take the url of the current page eg. http://www.example.com/example.html and put this in a link (among other uses) using javascript.

so it would look like this:

<a href"www.example.com/example.html"></a>

I’ve tried lots of things I know I need to use location.href but just can’t seem to get it to work.

This is the closest I got to getting it to work,:

<a href"javascript:write.location.href;"></a>

Thanks, sorry again. I’m new to JS and html.

J

  • 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-07T04:16:26+00:00Added an answer on June 7, 2026 at 4:16 am

    Name your element with an ID, like: <a id="pageLink"></a> and then when the document loads you can run this snippet:

    var link = document.getElementById("pageLink");
    link.setAttribute("href", window.location.href);
    

    Or, with something like jQuery:

    $("#pageLink").attr("href", window.location.href);
    

    EDIT In response to your question in the comments:

    I’m not sure I’m understanding you completely but if it’s fixed, then you’d simply concatenate to the href before setting it, e.g.

    $("#pageLink").attr("href", staticUrl + window.location.href);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have looked around on Google and StackOverflow for the answer to this question,
I have looked everywhere for the answer to this question, but cannot find anything
I have looked everywhere for the answer to this question and while there are
I have looked all over the internet for an answer to this question and
I have looked all over stack overflow, for the answer to this question, and
I have looked around on the Internet trying to answer this question. It seems
This is no doubt a newbish question, but I have looked for an answer
Having looked at this question, I have the following code: $/ = \0 answer
I have looked everywhere trying to find the answer to this question, I have
Have looked quite hard for this answer but having no luck. I have 3

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.