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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:58:29+00:00 2026-06-13T07:58:29+00:00

I have two html files: log_in.html and edit_story_name.html and two javascript files log_in.js and

  • 0

I have two html files: log_in.html and edit_story_name.html and two javascript files log_in.js and edit_story_name.js.

I initialized an object variable in log_in.js.

log_in.js

var User_Name= {value: "default_value"};    
var  Login_Password;

$(document).ready( function(){
$(' #public_User ').click( function(){

    $(' #log_in_account_txt ').val('publicUser');           
    $(' #log_in_psw ').val('publicUser');
    User_Name.value= "publicUser";

    alert("User_Name.value is"+ User_Name.value);
    window.open('edit_story_name.html','newwindow');        
});
});

As the user presses the button “public_User”, it will assign object variable’s value to be “pulicUser”.

Then the window “edit_story_name.html” will be opened.

edit_story_name.html:

<!DOCTYPE>
<html>
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="jquery-1.7.2.js"></s   ript>        

<script type="text/javascript" src="log_in.js"></script> 
<script type="text/javascript" src="edit_story_name.js"></script>
<link  type="text/css" href="edit_story_name.css" rel="Stylesheet"/>
</head>
<body>
<input id="input_story_name" type="text" value="">
</body>
</html>

edit_story_name.js:

window.addEventListener( "load",function(){
alert("User_Name.value is"+ User_Name.value);

if(User_Name.value == "publicUser"){
Story_Name="_story";
}else {                 

Story_Name= User_Name.value +"_story";
}


$(' #input_story_name').val(Story_Name);
});

Basically, after I press the button “public_User” in log_in.js, the User_Name’s value should change to be “publicUser”.
But no matter how hard I tried, the value remains: “default_value”.

Please help.

  • 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-13T07:58:30+00:00Added an answer on June 13, 2026 at 7:58 am

    Javascript variables last only for the lifetime of a single web page. In addition, each browser window has it’s own separate state. When you go to another web page in the same window, your javascript scripts are reinitialized again from scratch and contain none of the values from the previous page.

    Common methods for saving some state from one page that you can use in other pages are:

    1. Storing the value in a cookie
    2. Storing the value in local storage (only modern browsers)
    3. Storing the value on a server where the web pages can retrieve it
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two files: master/newsletter1/file.html master/newsletter2/file.html newsletter1/file.html has a lot of new changes that
I have three files in a folder 'test' one.php two.php print.html And i have
Hi all I have suppose two html files in my mobile application say page1.html
Afternoon, I am trying have an HTML file containing a frameset which contains two
I have two html pages on my webserver www.example.com/desktop.html www.example.com/mobile.html In principle the content
OK, I have two HTML select elements and a button. I need to disable
I have those two html radio buttons and textarea. I basically want to enable
lets say i have two pages links.html & contents.php ... first page contains only
I have two templates for my HTML email: one for bigger screens, and one
I have an HTML document where I have two different tables. One is class

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.