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

113
Vistas
Compare URL with string and path and insert link text

It is a post template that should work for different posts and in different languages. There should be no different templates for different languages. That's why I thought of the following. I compare the loaded url with string and path. If the condition is met, a URL and text will be added to the following link. Since I'm still at the beginning, I'm interested in your feedback and other approaches. Maybe you have any comments. So I can see what I can do better. Please help me so I can learn more. Thank you

var url = window.location.href
var path = window.location.pathname
var output1 = "http://localhost";
var output2 = output1 + path;

$(window).on('load', function () {
  if (url == output1 + path) {
    $("a.blog-wort").attr("href", "http://localhost/landing1/");
    $('a.blog-wort').text('text 1');
  } else if (url == output2) {
    $("a.blog-wort").attr("href", "http://localhost/en/landing2/");
    $('a.blog-wort').text('text 2');
  } else if (url == output2) {
    $("a.blog-wort").attr("href", "");
    $('a.blog-wort').text('text 3');
  }
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<a class="blog-wort"></a>

about 4 years ago · Juan Pablo Isaza
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