开发者

How to Get parent page information and from an Iframe and using the information to show a PHP page in the Iframe

开发者 https://www.devze.com 2023-01-25 23:46 出处:网络
I am creating widget with PHP. The widget will be a Iframe widget. Which will take the title of the parent page and pass the title to a P开发者_开发技巧HP page which will be seen with the result in th

I am creating widget with PHP. The widget will be a Iframe widget. Which will take the title of the parent page and pass the title to a P开发者_开发技巧HP page which will be seen with the result in the Iframe.


. Which will take the title of the parent page and pass the title to a PHP page which will be seen with the result in the Iframe.

This is going to be difficult if not impossible. If your widget runs on a different domain than the embedding page, you will not be able to access the parent page's title property due to the Same Origin Policy.


If you're on the same domain you should be able to use window.parent.document.title. If you're not on the same domain but have control of the parent you could pass the title in via a query string argument.


If you're parent and child (the iframed) pages are on the same domain, you can use something like:

parent.document.getElementById('id_of_element').whatever();

to access the parent window's data.

0

精彩评论

暂无评论...
验证码 换一张
取 消