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

129
Vistas
How to show current URL inside embed

<embed src="snippet.html"> - I need to insert the custom url(othersite.com/directory/something/) + "search part" of the current URL inside src attribute. I get that something like "console.log(window.location.search)" can help, but how could I connect/insert that to be inside src?

In short, my embed code output should looks like: <embed src="othersite.com/directory/something/astalavista"> , when the current URL looks like this mysite.com/info/astalavista

How should my HTML code look like?

I use Wordpress. Need HTML code. Thanks.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

Try this

const loc = new URL(location.href);
const lastPath = loc.pathname.split('/').pop();
const embed = document.createElement('embed');
embed.src = `https://othersite.com/directory/something/${lastPath}`
document.body.appendChild(embed)
about 4 years ago · Juan Pablo Isaza Denunciar

0

If you want to do it right in-place in your HTML, maybe not the best JS ever, but you can go:

some of your html...
<script>
  let myUrl = "whatever"; // or echo some php variable here?
  window.write(`<embed src="snippet.html/${myUrl}">`);
</script>
carry on with your html...
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