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

249
Views
¿Cómo cambiar la altura y el ancho de un iframe?

Obtuve este código para un bookmarklet de otro sitio web ( dublins ) pero quería modificarlo y cambiar la altura y el ancho al 100% de la página. Lo haría yo mismo, pero no sé cómo usar javascript. ¡Gracias!

 javascript:var url = prompt('What site do you want to embed into '+__uv.$get(location).href+'?%27);var%20prefix%20=%20%27https://%27;%20if%20(url.substr(0,%20prefix.length)%20!==%20prefix)%20{%20url%20=%20prefix%20+%20url;%20}%20var%20ifra=document.createElement(%27iframe%27);ifra.src=url;ifra.setAttribute(%27height%27,%27770%27);ifra.setAttribute(%27width%27,%271365%27);void(document.body.appendChild(ifra));
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Esto establece el tamaño del nuevo iframe .

 ifra.setAttribute(%27height%27,%27770%27);ifra.setAttribute(%27width%27,%271365%27);

La decodificación en JavaScript normal produce lo siguiente

 ifra.setAttribute('height','770'); ifra.setAttribute('width','1365');

Aquí, el ancho y el alto se establecen con atributos, pero los atributos no pueden especificar un tamaño basado en el tamaño de la página. Por lo tanto, use CSS de la siguiente manera.

 ifra.style.height='100vh'; ifra.style.width='100vw';

Ahora todo lo que tenemos que hacer es volver a poner esto en el bookmarklet. Reemplace la primera parte con la siguiente.

 ifra.style.height=%27100vh%27;ifra.style.width=%27100vw%27;

Entonces, el bookmarklet completo está a continuación.

 javascript:var url = prompt('What site do you want to embed into '+__uv.$get(location).href+'?%27);var%20prefix%20=%20%27https://%27;%20if%20(url.substr(0,%20prefix.length)%20!==%20prefix)%20{%20url%20=%20prefix%20+%20url;%20}%20var%20ifra=document.createElement(%27iframe%27);ifra.src=url;ifra.style.height=%27100vh%27;ifra.style.width=%27100vw%27;void(document.body.appendChild(ifra));

Pero lamento no haberlo probado porque su bookmarklet no funcionó en mi extremo.

about 4 years ago · Juan Pablo Isaza Report

0

<iframe style="width: 100px; height: 100px; background: red"></iframe>

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!