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

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.
Ravi KallaTechnology LeadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
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.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.