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. Learn more


Example code

<script>
    function onMessage(event) {
        if (event.data && event.data.riddleEvent) {
            var riddleData = event.data.riddleEvent;
            if ('object' === typeof (riddleData)) {
                if ('object' === typeof (riddleData)) {
                    // Reload iframe
                    $('#google-ads-iframe').attr('src', $('#google-ads-iframe').attr('src'));
                    
                    // Pure JS - no jQuery
                    //document.getElementById('google-ads-iframe').contentWindow.location.reload(true);
                }
            }
        }
    }
    window.addEventListener("message", onMessage, true);
</script>