How to select elements inside iframe with Javascript

preview_player
Показать описание
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

// FREE resources

// Premium content

// Discounts
🎢 Get 10% GSAP: WEBBAE10

// Connect
Рекомендации по теме
Комментарии
Автор

Hello man, I need help about a Wordpress plugin called chatway, they have form submission inside chatbox but trying to submit from it, it does not forward as non hubspot form.

JohnPaulCorrea-it
Автор

New stuff learned.

Never know we can use queryselector on top of contentdocument.

Spent few days finding way to manipulate data inside frame tag.

Irzani
Автор

Thanks for the video! I have always been curious about how to style something inside an iframe. 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.

GrifanoRide
Автор

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

StevenCookFX
Автор

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

JitinMaherchandani
Автор

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

smartpythonguy