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

201
Views
Pasar variables jquery entre iframe y padre

¿Cómo puedo trabajar con jQuery e iframe ? Obtenga y pase var de iframe a body y de body a iframe . Tengo el siguiente ejemplo. ¿Cómo puedo hacer clic en el botón en iframe y hacer que tenga efecto en el #test del body ? ¿Qué tal ready var x en iframe?

 <body> var x = "whatever"; <div id"test"></div> <iframe width="200px" height="200px" src="page.html"></iframe> </body>

Dentro de page.html tengo

 <button>clickme</button> <script> var elm = $('<span>content</span>'); elm.appendTo('#test') </script>
over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

$("#myid", top.document);

o

 $("#myid", parent.document.body);

Esto le dará acceso al contenedor del IFRAME

según: http://groups.google.com/group/jquery-en/browse_thread/thread/5997ef4a60a123af

over 4 years ago · Santiago Trujillo Report

0

Desde la perspectiva de los padres:

 var iFrameValue = $('#iframe').get(0).contentWindow.myLocalFunction();

O

 var iFrameValue = $('#iframe').get(0).contentWindow.myLocalVariable;

Desde la perspectiva del iframe

 <script type="text/javascript"> var myLocalVariable = "hello"; function myLocalFunction () { return "hello"; } </script>
over 4 years ago · Santiago Trujillo Report

0

Puede usar las propiedades contentWindow y contentDocument , si la misma política de origen no es un problema. He configurado una demostración . Ver código para la demostración y código para iframe .

over 4 years ago · Santiago Trujillo 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!