How to load a page in one iframe using the javascript that resides in different iframe

Posted on 2014-07-11
Medium Priority
Last Modified: 2014-07-24
A parent window contain two iframes. Lets say "iframe1" and "iframe2".
When I click on a button in iframe1, corresponding HTML should be loaded in iframe2.

I have written below code in javascript in iframe1 to accomplish that -
 parent.document.getElementsByName('iframe2')[0].src = "http://localhost/test.html";

Open in new window

This is working fine when parent window and iframes are in same domain. When they are in different domain, I am getting a javascript access error. I tried setting "document.domain" property of child iframe to the one corresponding to the parent and it didn't work.

Please suggest any alternate solutions.
Question by:Ravi Kalla
LVL 29

Accepted Solution

becraig earned 2000 total points
ID: 40191559
Here is some good reading on this, some other experts may have more recent solutions as I have not worked with this in a while:

LVL 54

Expert Comment

by:Scott Fell, EE MVE
ID: 40191746
I don't think what you are trying to do is possible as you describe.  

Just thinking out loud, what about framed site A gets updated and talks to the server and the server.  Then page that is in the other frame  has data pushed out and updates.  


Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this blog, we’ll look at how improvements to Percona XtraDB Cluster improved IST performance.
In this tutorial viewers will learn how to position overlapping items using z-index in CSS. They will also learn the restrictions on the z-index property.  Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Red.…
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Suggested Courses

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question