Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am writing a signage html page to be shown in full screen automatically. I use screen.width and .height to get the client's screen size. Now for the edit page which users can add/delete contents on the signage, I would like to let users preview the edited result without going to signage site in fullscreen. So I plan to have a iframe has the same ratio as the client screen and embedded the signage page into the iframe on the edit page.

The thing is how I can let the signage page change the size to fit in the iframe? Or how I can get the parent page's iframe from the embedded page? The screen.width and $(document).width seem to have the same result.

I use python GAE, webapp2,jinja2.

like image 440
Russj Avatar asked Aug 19 '13 02:08

Russj


People also ask

How do I get parent iframe?

var iframe = parent. document. getElementById(frameElement.id);

Can an iframe get parent URL?

Yes, accessing parent page's URL is not allowed if the iframe and the main page are not in the same (sub)domain. However, if you just need the URL of the main page (i.e. the browser URL), you can try this: var url = (window. location !=

What is iframe height?

The standard size of an iframe for desktop is a width of "560" and height of "315."


1 Answers

Within the embedded page you can retrieve the size of the iframe element in the parent page like this:

var width = window.frameElement.offsetWidth,
    height = window.frameElement.offsetHeight;
like image 109
Teemu Avatar answered Oct 27 '22 00:10

Teemu