Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

112
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda