问题
I have a page that calls another page(on another server) and I want that page to read the title from the parent page. Is this possible or is there some security issue with this?
回答1:
You cannot communicate across servers like that.
回答2:
You can use JavaScript to access the parent:
window.parent.document.title
回答3:
Call page A the caller page (with the JavaScript on it, the one requesting the title) and page B the page you want the title of.
Can you make a third page C (hosted on any server where A can access C and C can access B) which acts a go-between and servers up a JSON or XML request from the target page to the source page (where the JavaScript can call it?)? Page C could be any web app or CGI program capable of pulling down the HTML of page B and parsing it for the title, and then serving up the result in an AJAX friendly manner for page A to consume.
I suppose the usefulness of this depends on your goals and bigger-picture point of view of your project.
来源:https://stackoverflow.com/questions/1139632/how-can-i-read-the-page-title-of-the-parent-page-from-an-iframe