# \[PAID\] - Trigger a javascript when new posts are loaded and House Ad-plugin adds a div

**URL:** <https://meta.discourse.org/t/paid-trigger-a-javascript-when-new-posts-are-loaded-and-house-ad-plugin-adds-a-div/238419>\
**Category:** Marketplace\
**Created:** [September 8, 2022, 7:27am UTC](https://meta.discourse.org/t/paid-trigger-a-javascript-when-new-posts-are-loaded-and-house-ad-plugin-adds-a-div/238419 "2022-09-08T07:27:49Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![janbolmeson](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/janbolmeson/32/192162_2.png) [@janbolmeson](https://meta.discourse.org/u/janbolmeson)\
**Post date:** [September 8, 2022, 7:27am UTC](https://meta.discourse.org/t/paid-trigger-a-javascript-when-new-posts-are-loaded-and-house-ad-plugin-adds-a-div/238419/1 "2022-09-08T07:27:49Z")

</div>

I am trying to add ads to my Discourse-forum and I am kind of stuck and I would need some help from you guys, if possible.

Background:

- I am using the [official adsplugin](https://meta.discourse.org/t/house-ads-in-the-official-ad-plugin/116715) with the “house ads” setting to add a html-tag e.g `<div id="rikatillsammans_desktop-panorama-1_c"></div>` every 10th post. This works.

- In order to fill that div with content - I would need to trigger a javascript such as:

```plaintext
    lwhb.cmd.push(function() {
        lwhb.loadAd({
            tagId: 'rikatillsammans_desktop-panorama-1_c',
        });
    });

```

But the problem is that I don’t know how to load it.

If I add it to the house-ad-function so it includes the code with the div, it does not seem to get executed. I.e. I cannot add the javascript to the house ad-html.

Possible?

Best regards,  
Jan

---

_[View the full topic](https://meta.discourse.org/t/paid-trigger-a-javascript-when-new-posts-are-loaded-and-house-ad-plugin-adds-a-div/238419)._
