Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
How to read a variable declared in a html file inline script to another html inline script

I have two html files e.g. abc.html & rst.html. abc.html has inline script having a variable x declared inside it with some value. Now I want to access the x value inside rst.html file's inline script. Could you please let me know if this is possible.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can't.

JavaScript does not let you access other tabs (to some extend, you may be able to access <iframes>s which could be in a separate window, but that's it and newer browsers generally prevent such accesses).

While in your browser, you have access to one set of global variables that are in that one window. Anything else is not accessible for security reasons.

The only way you would be able to do that is by using AJAX to read the second file and then search for the variable and grab the value. Good luck doing that...

The simplest for you will be to create a file, say x.js, and load that in both HTML pages. Now you will have access to all the data found in x.js.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!