How to get the parent size of the iframe in the embedded js code of the page?

I am writing an HTML signage page that will be displayed in full screen automatically. I use screen.width and .height to get the client screen size. Now for the editing page that users can add / remove content on the signboard, I would like to allow users to view the edited result without visiting the signage site in full screen mode. Therefore, I plan to have an iframe with the same ratio as the client screen, and embedded the signage page in the iframe on the edit page.

How can I let the signage page resize to fit the iframe? Or how can I get the parent iframe page from the inline page? It appears that screen.width and $ (document) .width have the same result.

I am using python GAE, webapp2, jinja2.

+4
source share
1 answer

The built-in page, you can get the size of the element iframe on the parent page, as follows:

 var width = window.frameElement.offsetWidth, height = window.frameElement.offsetHeight; 
+7
source

Source: https://habr.com/ru/post/1497719/


All Articles