can an cross-domain iframe detect a browser's

2020-07-25 10:13发布

I have an iframe loaded inside a parent page - the iframe and parent page are on different domains.

Can my iframed site detect the actual browser dimensions?

3条回答
ゆ 、 Hurt°
2楼-- · 2020-07-25 10:29

I ended up using the excellent postMessage plugin from Ben Alman

http://benalman.com/projects/jquery-postmessage-plugin/

this allows for cross domain communication where you have control over both domains.

查看更多
叼着烟拽天下
3楼-- · 2020-07-25 10:34

The simple answer, is no. It cannot. Unless by some means the parent window can dynamically send data to the object inside the iframe...

However if the content inside the iframe was all made in %'s so that it would scale nicely (similar to a fluid web page layout), this could help?

What is it that you are directly trying to achive?

查看更多
可以哭但决不认输i
4楼-- · 2020-07-25 10:53

You can use the web API window.postMessage method too. It safely enables cross origin communication.

https://developer.mozilla.org/en-US/docs/Web/API/Window.postMessage

查看更多
登录 后发表回答