• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

Detect iframe and load iframe as main page

We've got a website (http://www.wiops.com/) which has a search box that just uses Google search with site:wiops.com.  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.
0
quizwedge
Asked:
quizwedge
  • 3
  • 2
1 Solution
 
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;

0
 
scrathcyboyCommented:
"How do we make it so that clicking on the link changes the main page instead of the iframe"

<A href="http://www.somesite.com/somelink.html" 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.
0
 
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
scrathcyboyCommented:
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.
0
 
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; 
		}
    }

RedirectiFrameSearch();

Open in new window

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

Join & Write a Comment

Featured Post

Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now