javascript - How can I read the page title of the parent page from an iframe? - Stack Overflow

I have a page that calls another page(on another server) and I want that page to read the title from th

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?

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?

Share Improve this question edited Jul 16, 2009 at 19:11 Motti 115k56 gold badges194 silver badges274 bronze badges asked Jul 16, 2009 at 19:01 Ryan DetzelRyan Detzel 5,59910 gold badges38 silver badges50 bronze badges 1
  • I need it for an ad. A website is running our ads in a iframe but the ad needs access to the page title to properly target. So, the page and iframe are on their server then they execute the ad script in the iframe so I need to grab the parent's title. Possible? – Ryan Detzel Commented Jul 16, 2009 at 19:32
Add a ment  | 

3 Answers 3

Reset to default 2

You cannot municate across servers like that.

You can use JavaScript to access the parent:

window.parent.document.title

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744835819a4596255.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信