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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T14:36:21+00:00 2026-05-14T14:36:21+00:00

I am somewhat new to web developing, so I am trying to learn along

  • 0

I am somewhat new to web developing, so I am trying to learn along the way. I have a div that is 500 x 500. Inside of that div I have two divs that are each 250×500. So my outer div is filled up with the two inner divs.

I have it setup so that when I click on the first div (the left one) a JavaScript is called, and a prompt pop up box asks for a website URL which is then stored inside of a string variable.

How can I make it so that the second div (the right one) takes the string variable from the alert box from the left div and puts it into an a href tag so that I can link to the website from the right div?

Can a a href tag accept a value from a variable for its link? Maybe I am going about this all wrong, is there a better way I should be approaching this? Any help is appreciated!

  • 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-14T14:36:22+00:00Added an answer on May 14, 2026 at 2:36 pm

    There’s the DOM creation method:

    // Create an element
    var aEl = document.createElement("a");
    
    // Ask the user for the URL
    aEl.href = prompt("Please enter the website URL");
    
    // Determine whether to use innerText or textContent
    if ("innerText" in aEl)
        aEl.innerText = aEl.href;
    else
        aEl.textContent = aEl.href;
    
    // Add the link to the right div
    document.getElementById("rightDiv").appendChild(a);
    

    Or the straight-up innerHTML method:

    var url = prompt("Please enter the website URL");
    document.getElementById('rightDiv').innerHTML = '<a href="'+url+'">'+url+'</a>';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Our group is somewhat new to JVM based development. We are developing applications that
I have a web application using EF4. I am somewhat new to EF and
I'm somewhat new to Wordpress. I'm primarily a front-end web designer, and I use
I am somewhat new to android development and development in general. I have a
I am somewhat new to LINQ and have a quick question regarding deleting. Say,
I am relatively new to ASP.NET programming, and web programming in general. We have
I have a web application that uses a relational database (MySQL). We're adding a
I have implemented a web crawler that crawls and retrieves content from .edu TLD.
I am new to the concept of MVC and multi-tiered web architecture. I developing
I am somewhat new to web development, so I'm not sure how stupid this

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.