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

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

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 Relatório

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 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