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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:58:06+00:00 2026-05-25T16:58:06+00:00

For example: function change() { document.getElementById(‘identification’).href = http://www.stackoverflow.com; } The associated HTML (the important

  • 0

For example:

function change()
{
document.getElementById('identification').href = "http://www.stackoverflow.com";
}

The associated HTML (the important bit)


<a href="#" id="identification">Stack Overflow</a>
<input type=button value="Change" onclick="change()" />

This will change the href in my tag to http://www.stackoverflow.com, but say I wanted to do this from a different HTML file? The JavaScript would be in the tag of the other file, but would edit the content of the first. Is this possible? If so, how?

  • 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-25T16:58:07+00:00Added an answer on May 25, 2026 at 4:58 pm

    Javascript lives only for the life of a particular page so you can’t have code in one file modify another, as yet unloaded file.

    Depending upon what you want the user experience to be, there are some options:

    1. While on the first page, use some javascript to set a cookie and then when the second page loads, read that cookie and have the javascript in the second page adapt based on the cookie value. Cookies can be shared between pages on the same domain.
    2. While on the first page, use some javascript to create a query parameter (those things after the ? in a URL that look like this ?show=true. When you load the second page, request that page by appending the ?show=true (or whatever you make up) to the end of the URL. When the second page loads, it can examine the query parameters on it’s URL and decide how to modify itself. This is the simplest way of passing temporary arguments from one page to the next page.
    3. Load the second page into an iframe (embedded into the first page) and when it’s loads, your javascript can modify it (if it is served from the same domain as your main page).
    4. Load the second page into your first page, actually inserting it into the original page either appending it or replacing some of your existing content. Then, the first page’s javascript can modify the HTML from the second page once it has been inserted.
    5. Open a new window with the new page in it. If it’s on the same domain as you, then your javascript can reach into that new page and modify it.

    Note: the browser tries to prevent page modifications when the two pages do not have the same origin (e.g. same domain). See a description of the same origin policy. So, if your question pertains to pages on different domains, then you will need to find a different way to solve your problem. Things like add-ons can sometimes get around the same-origin policy, but regular page javascript cannot for numerous security reasons.

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

Sidebar

Related Questions

Hi i have a problem with recursion. i followed this example from wc3 http://www.w3schools.com/jsref/met_win_settimeout.asp
I am trying to utilize the example cited here: http://www.physicsforums.com/showthread.php?t=248191 I wrote a simple
Is this possible? example: $('a.change').click(function(){ //code to change p tag to h5 tag });
I want to change the default arguments passed to a Ruby function. For example,
For example: (function() { var proxied = window.eval; window.eval = function() { return proxied.apply(this,
I have an example function below that reads in a date as a string
So I have some openGL code (such code for example) /* FUNCTION: YCamera ::
I'm pretty new to XQuery and I'm trying to write an example function that
I have a simple question related to one-line programming. First an example: function test(a)
Example: /** * This function will determine whether or not one string starts with

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.