Detect iframe and load iframe as main page

We've got a website ( which has a search box that just uses Google search with  If you search for something, e.g. Sprint, it loads the search results in an iframe which is what we want.  The problem is that if you click on a link, it loads the entire site in the iframe so you have two copies of the template.  I know we can't change Google's page.  How do we make it so that clicking on the link changes the main page instead of the iframe so that the site looks correct?  The site is built in ColdFusion.
LVL 14
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Gurvinder Pal SinghCommented:
If you have the Id of the iframe, then all you need to do is

var iframHTML = document.getElementById('iframeId').innerHTML;

document.getElementsByName('body').innerHTML = iframHTML;


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
"How do we make it so that clicking on the link changes the main page instead of the iframe"

<A href="" target= "parent"> show in main page </A>

Parent refers to the main page, and the iframe name refers to the iframe.  If the iframe is called "Ifram", then replace "parent" above with "ifram" -- which will send the link to the iframe, not the parent.
quizwedgeAuthor Commented:
Sorry, haven't had a chance to try qurvinder372's solution.  scrathcyboy's solution won't work since we don't control the output... it comes direct from Google.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Had you said that in the original question, my response would be, you can't dynamically fix dynamic output from Google, without saving it, changing it, and uploading it.
quizwedgeAuthor Commented:
qurvinder372, went to implement this.  I think your solution would work, though it seems to me like there would be two <head> sections since you'd have the <head> from the parent and then the <head> from the iframe's innerHTML.  If not, then if there was something in the <head> of the iframe it'd be missing.

You get the points, but wanted to post the solution that made more sense to me.

Thanks for the help.
function RedirectiFrameSearch()
		if(window.location != top.location)
			top.location = window.location; 


Open in new window

quizwedgeAuthor Commented:
While this seems like it would work, see my solution below for what seems to be a better solution.
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.