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

181
Vistas
HTML anchor tag have href first then onclick()

In an anchor tag with both href and onClick, is it possible to have the href first go to the link then execute the onClick()?

For example, I want this anchor tag to first go to the link and then call the highlightButton function.

<a
  class="page-link" 
  href="?page={{step.previous_page_number}}" 
  onClick="highlightButton();"
  aria-label="Previous"
>Previous</a>
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Nope. You can, however, check and validate the parameter page from the URL when the document is ready then execute the highlightButton() function.

Example:

HTML

<a class="page-link" href="?page={{step.previous_page_number}}" aria label="Previous">Previous</a>

javaScript

document.addEventListener("DOMContentLoaded", function() {
    const params = new URLSearchParams(location.search);
    const page = params.get("page");

    // Example Validation
    if (page != "" || page != null) {
        highlightButton();
    }

    function highlightButton() {
        // Code goes here
    }
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

No, You cannot do that, by opening a new link, the last page wont work at the background but if you want to use a specific function in the next page, just write the function and call it at the top of your script tag!

Like this :

<script>
    highlightButton()
    function highlightButton() {
        // your code 
    }
</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