2

I have a parent page and inside that parent page, there is an iframe that is around half the size of the parent page.

The JavaScript in the iframed page is supposed to get the size of the iframed page and set the size of a text input, but both JavaScript's document.body.clientWidth and jQuery's $(document).width() are returning the parent page's width.

How do I get the width of the iframed page from scripts inside the iframe (that is, without having to send the iframe width from the parent page to the iframe page with querystrings)? They are cross-domain too.

ketan
  • 19,129
  • 42
  • 60
  • 98

2 Answers2

0

simply use this -

<iframe src="demo_iframe.htm" width="200" height="200"></iframe>
SMT
  • 469
  • 1
  • 5
  • 17
  • 1
    yes, but that won't help get the width of the iframed page in the iframed page! I know how to make iframes, obviously. – bungularbike Jul 02 '15 at 10:14
  • The similar kind of work is done here http://stackoverflow.com/questions/7808729/detect-iframe-height-and-width-from-inside-the-iframe you can refer this if it works – SMT Jul 02 '15 at 10:27
0

The similar kind of work is done here stackoverflow.com/questions/7808729/… you can refer this if it works – Manoj Singh

Thank you, this is exactly what I wanted!

EDIT: Sorry, after a bit of testing, this doesn't work too well. In jsfiddle it works, but in my page, it only gives me the height accurately.