This example shows you how to refresh ad units on your page when the Riddle advances to the next question. Make sure to alter the script by inserting the ID of the DIVs containing your ads.

function onMessage(event) {
    if ( && {
        var riddleData =;
        if ('object' === typeof (riddleData)) {
            // Reload iframe
            $('#google-ads-iframe').attr('src', $('#google-ads-iframe').attr('src'));
            // Pure JS - no jQuery
window.addEventListener("message", onMessage, true);

Learn more here:

The blog post above also explains in detail how to use the ad refresh script in various environments like WordPress, so please head on over there if you get stuck.

Leave a Comment