I want to give the class name to the iframe tag of the advertisement installed on the site.

Asked 1 years ago, Updated 1 years ago, 20 views

·I would like to give the class name to the iframe tag of the advertisement installed on the site
·How should I write it?
·Do I need to wait for iframe to appear?

·iframe.className="hoge"?
·AddClassName is not standard?

javascript

2022-09-30 11:44

1 Answers

If you are using the raw DOM API, use getElementById() to get the DOM element and replace the space-separated class name with element.className.Recent browsers also seem to be easy to add with element.classList.add().

I think the addClassName() you mentioned is the protocol.js method.

Do I need to wait for iframe to appear?

The DOM element must have been generated so that it can be manipulated.

You may just need to write behind the tag that embeds the ad, but if that doesn't work, you'll have to wait for the iframe to be generated or loaded in some way.The iframe load event does not appear to be bubbling, so I think it will be like using Mutation Observer or monitoring with a timer.


2022-09-30 11:44

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.