0

I have a widget on a site that is loaded externally with a third-party <script>.

I need to manipulate DOM in their widget. Is there any way I can do this without a callback in their external script?

geochanto
  • 972
  • 2
  • 13
  • 45
  • 2
    Once the HTML has been loaded into the DOM, it doesn't matter where it came from. You manipulate it the same way. – Barmar Oct 01 '19 at 17:37
  • Are you asking how to know when the widget has made its DOM modifications, so you can do your own manipulations on the result? See https://stackoverflow.com/questions/3219758/detect-changes-in-the-dom – Barmar Oct 01 '19 at 17:40
  • @Barmar I suppose so. When I just try to manipulate widget's HTML, nothing works. – geochanto Oct 01 '19 at 22:10
  • If you provide a link to the widget and its documentation, someone may be able to find a specific solution for you. – Barmar Oct 02 '19 at 16:42
  • @Barmar sadly its a commercial provider with no documentation and no public codebase. – geochanto Oct 02 '19 at 17:45
  • In that case I hope they provide technical support and can help with a way to tailor the product to your needs. – Barmar Oct 02 '19 at 18:10
  • @Barmar thanks for your feedback. I just needed setinterval to check whether widget existed in the DOM first, and only then do DOM manipulation. – geochanto Oct 08 '19 at 05:05
  • 1
    That's a kludgey way to do it, but it will work. `MutationObserver` is a more direct way, but a little more complicated. – Barmar Oct 08 '19 at 05:55

0 Answers0