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

161
Views
¿Cómo usar de forma segura el símbolo "&" en una variable de javascript sin que se convierta en "&"?

Estoy tratando de ejecutar el siguiente código:

 <button onclick="increment()">Increment</button> <div id="iframe"> <script> var id = 139000; var link='<iframe src="https://somewebsite.com/something.aspx?sa=1&pid=' + id + '" height="600px" width="100%" />'; function increment(){ id++; document.getElementById('iframe').innerHTML = id + link ; } </script> </div>

Pero durante la ejecución, & en src="" se convierte en &amp; que rompe la URL original y no va al destino deseado. Busqué en Internet, pero como soy un novato, no pude resolverlo. ¡Por favor, ayúdame a hacer que esto funcione!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Todo lo que necesitas hacer es

 <button onclick="increment()">Increment</button> <div id="iframe"> <script> var id = 139000; var link='<iframe src="https://somewebsite.com/something.aspx?sa=1&pid=' + id + '" height="600px" width="100%" />'; var new_link = link.replaceAll('&amp;','&'); function increment(){ id++; document.getElementById('iframe').innerHTML = id + new_link; } </script>
about 4 years ago · Juan Pablo Isaza Report

0

Este es definitivamente un problema de Blogger, y la razón detrás de esto es:

El carácter "&" es un carácter reservado de HTML ISO que se utiliza para indicar el inicio de un parámetro.

Para solucionar esto, el editor de Blogger traduce el & que ingresa a la entidad HTML, &amp; , que se mostrará & cuando la página o URL se represente en un navegador, para que no tenga que hacerlo usted mismo.

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!