How to select elements inside iframe with Javascript

Поділитися
Вставка
  • Опубліковано 26 лип 2022
  • In this tutorial I explore how to query HTML elements inside of an iframe on your webpage using the contentDocument property and querySelector() function. This allows the code to click another button on the page when user clicks Submit on an embedded Hubspot form.
    // TRY WEBFLOW
    👉 try.webflow.com/webflow-is-bae
    // FREE resources
    ✂️ Code Snippet Library: code-snippets-sign-up.webflow...
    🤝 CSS Nobody Told You About: www.webbae.net/css-nobody-tol...
    🚗 Roadmap to learn Webflow: www.webbae.net/roadmap-to-lea...
    // Premium content
    🤝 Patreon: / webbae
    🕸️ Advanced Webflow Course (201): www.webbae.net/product/webflo...
    // Discounts
    🎢 Get 10% GSAP: WEBBAE10
    ♣️ Creative Coding Club (My favorite GSAP lessons): www.creativecodingclub.com/bu...
    // Connect
    🙋‍♀️ Join the Discord: / discord
    🐥 Follow Me! / webisbae
  • Навчання та стиль

КОМЕНТАРІ • 20

  • @camputty1827
    @camputty1827 2 роки тому

    You rock man!

  • @Irzani938
    @Irzani938 Рік тому +2

    New stuff learned.
    Never know we can use queryselector on top of contentdocument.
    Spent few days finding way to manipulate data inside frame tag.

  • @Idiomeme_com
    @Idiomeme_com Рік тому +1

    very good

  • @JosephBosas
    @JosephBosas 7 місяців тому

    amazing. it works

    • @webbae
      @webbae  7 місяців тому +1

      Glad I could help!

    • @JosephBosas
      @JosephBosas 7 місяців тому

      yeah brother keep up the great work@@webbae

  • @Grifanos
    @Grifanos Рік тому +2

    Thanks for the video! I have always been curious about how to style something inside an . But looks like this isn't work for me 🤔
    I've tried using this method for clutch widgets, and also for Freshdesks, but this isn't work for me. contentDocument is always returned null, and quarySelector doesn't work.

    • @webbae
      @webbae  Рік тому

      Unfortunately it doesn’t always seem to work - depends on the

    • @Rob-co6iz
      @Rob-co6iz 2 місяці тому

      Sounds like the issue is with the CORS policy of the source of the content.

  • @StevenCookFX
    @StevenCookFX 6 місяців тому +1

    it works for a little while then breaks. Not sure why but there is a change somewhere that turns the variable to null

    • @webbae
      @webbae  6 місяців тому

      😢 sorry it’s not working for you! I frames can be weird sometimes…

  • @smartpythonguy7868
    @smartpythonguy7868 Рік тому +1

    Hi when I run javascript on it block that request.(same origin policy ) Any solutions?

    • @webbae
      @webbae  Рік тому

      hey I don't think you can get around that one :(

  • @JitinMaherchandani
    @JitinMaherchandani 2 місяці тому +1

    Is there a way to disable this? Speaking on behalf of an

    • @webbae
      @webbae  2 місяці тому

      honestly not sure. s don't speak my language usually. 🙃

  • @quangngo4432
    @quangngo4432 Рік тому +1

    cross-origin frame

  • @matteokarol
    @matteokarol 10 місяців тому

    how to for each frameObj.contentDocument.querySelectorAll("js-post__content-text restore h-wordwrap")forEach[].innerHTML;

    • @webbae
      @webbae  10 місяців тому +1

      hey... sorry... I'm not sure :(

    • @matteokarol
      @matteokarol 10 місяців тому

      @@webbae no problema.🙂

    • @matteokarol
      @matteokarol 10 місяців тому

      @@webbae hi how to put classname in