amp-ad : get dom or container properties?
From within a DFP amp-ad, is there a way to get top document DOM properties? For example I'm trying to get the browser width via window.top.innerWidth but am hitting cross-origin errors. I don't see any methods within context to obtain any page-level element properties other than these.
Alternatively, is there a way to use units other than 'px' within a call to context.requestResize? I'd like to set the width of the container to be the full width of the browser either with 100vw or 100% (or by getting the width of the page in pixels and using that value which is why I'm asking about getting top document DOM properties).
/to @lannka
/cc @bradfrizzell
Would the window.context.observerIntersection return value not supply this? I believe that is what rootBounds gives you, no? I am currently on a train and my wifi is crap so I am unable to get my testing environment to work, but I can double check when I am back in the office.
@bradfrizzell Can you point me to any documentation regarding rootBounds and observerIntersection? I've been digging around quite a bit and I haven't come across it. Thanks!
@coreybyrnes @bradfrizzell I don't suggest relying on observerIntersection API for the window size.
A better one will be the proposed PositionObserver API: #6873 .
But still, that would be considered expensive if all you want is parent window size. We can introduce a specific API for that.
Or alternatively, let me explore the option for 100% and 100vw first.
Does requestResize take anything other than a pixel value? It does not appear so to me. Either way, the argument's units is not well documented anywhere in the code.
@bradfrizzell Unfortunately not - you simply set a numeric value, not a string including a unit. That was part two of my question. If you can specify a unit as the third paramater or ideally make the unit a part of the parameter (with px being a fallback if no unit is included).
@bradfrizzell @coreybyrnes yep, that's a feature missing. I'll take a look how easy it is.
@lannka Awesome! Thanks.
@lannka does this still need to be prioritized? Thanks.
the discussion was continued (and stalled) in #8095 . we can close this