Skip to content Skip to sidebar Skip to footer

Is There A Way To Expand An Advert Outside Of The Window Width Within A Gpt (google Publisher Tag) Safeframe?

I am trying to create an advert that will expand past the side of the page. Using the GPT Safeframe preview tool I am receiving the error 'Invalid EXPAND_REQUEST message. Reason: V

Solution 1:

unfortunately, it's not possible to avoid this behaviour, but i made a workaround, that will "wait", until user is scrolled in place, that is suitable to expand, check this example, that will push banner from bottom, when user have enought space from bottom to expand whole creative:

<divid="container">
    some lines to make container height<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br>
    line<br><script>// global expanded indicator variable, because API don't have any var expanded = false;
        functionexpand() {
            var self= $sf.ext.geom().self;
            var config = {
                push: true,
                b: 0
            };

            var el = document.getElementById('container');
            var containerHeight = el.offsetHeight;

            // get height from bottom, that need to be expandedvar expandBottom = containerHeight - self.h;

            // if container is whole inside a SafeFrame, it will not expandif(expandBottom < 0) return;

            config.b = expandBottom;
            $sf.ext.expand(config);
        }

        functionexpandDelayed(forceExpand) {
            // expand will run just once, or you can force it to run again// but collapse first is neededif(expanded && forceExpand || !expanded) {
                $sf.ext.collapse();
                expanded = false;
                // there must be some timeout, because .collapse(); method is deplayed somehowsetTimeout(expand, 0);
            }
        }

        $sf.ext.register(160, 150, function(status, data) {
            // this code will do whole magic of "waiting" for right momentif (status === 'geom-update') {
                expandDelayed();
            }

            // change global expanded statusif (status === 'expanded') {
                expanded = true;
            }
        });

        // initexpandDelayed();
    </script></div>

hope it helps!

edit:

I found better solution here: Unable to access contents of a safeframe returned by Google adx

Post a Comment for "Is There A Way To Expand An Advert Outside Of The Window Width Within A Gpt (google Publisher Tag) Safeframe?"