Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

99
Vistas
Single Page Application using injector - Javascrip reload the page

I am making a single page application using injection function :

<html>
<body>
<a href="javascript:injector('../../url1')"> link1 </a>
<a href="javascript:injector('../../url2')"> link2 </a>
<iframe id="iframe" width="100%" src=""></iframe>
</body>
</html>

<script>
function injector(url) {
 window.parent.document.getElementById("iframe").src = url;
}
</script>

There are 2 urls in this simple example. I can save the one that has been clicked on local storage. But:

  1. how do I explain in JavaScript (When the page is refreshed, use the last used url automatically)
  2. How to deal with going back to a previous page (a previous url). Is there a better way to deal with navigation in single page application using JS?
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

here, whenever you click on link it will load url in iframe and when you do fresh it will load from localstorage itself.

<html>
<body>
<a href="javascript:injector('https://merolagani.com/')"> link1 </a>
<a href="javascript:injector('https://bizmandu.com/')"> link2 </a>
<iframe id="iframe" width="100%" src=""></iframe>
</body>
</html>

<script>
    var iframe = document.querySelector('iframe#iframe');
    iframe.src=localStorage.getItem('url');
    function injector(url) {
        iframe.src = url;
        localStorage.setItem('url',url);
    }
</script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda