Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

135
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!