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

236
Views
Obtenga datos de iFrame dataLayer, pero obtenga un error: contentWindow = null

Estoy tratando de obtener datos de un formulario de HubSpot en una variable de JavaScript personalizada.

Puedo hacer que el elemento se vea en la columna usando querySelector, el código es el siguiente:

 <script type="text/javascript"> var iframe = document.querySelector('iframe'); var contactType = iframe.contentWindow.document.querySelector('[name="how_can_we_help_you"]').value; window.addEventListener("message", function(event) { if(event.data.type === 'hsFormCallback' && event.data.eventName === 'onFormSubmitted') { window.dataLayer.push({ 'event': 'hubspot-form-success', 'hs-form-guid': event.data.id, 'hs-form-contact' : contactType, 'hs-form-contact1' : event.data }); } }); </script>

Entonces puedo ver el error:

 Uncaught TypeError: Cannot read properties of null (reading 'contentWindow') at <anonymous>:1:64 at gtm.js?id=GTM-WJPP59F:428:414 at b (gtm.js?id=GTM-WJPP59F:429:337) at se (gtm.js?id=GTM-WJPP59F:87:769) at e (gtm.js?id=GTM-WJPP59F:211:34) at gtm.js?id=GTM-WJPP59F:37:130 at Array.<anonymous> (gtm.js?id=GTM-WJPP59F:212:454) at Object.execute (gtm.js?id=GTM-WJPP59F:212:194) at hs (gtm.js?id=GTM-WJPP59F:309:1124) at qs (gtm.js?id=GTM-WJPP59F:314:20)

Cualquier ayuda sería muy apreciada gracias!

about 4 years ago · Juan Pablo Isaza
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!