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.
精彩评论