1

I have a webpage with an iframe. What I want to be able to do is have the query string from the iframe pass through the parent url.

For example: Parent URL: mysite.com/iframe-page

iframe URL: iframe.com

When a link is clicked on in the iframe the iframe url changes to "iframe.com/?filter=google"

I would like it set up so that the parent url could start as mysite.com/iframe-page then when the link in the iframe is clicked the url changes to mysite.com/iframe-page?filter=google

Is this something that is possible to do?

1 Answers1

0

Links in the IFRAME can target the parent

<a href="mysite.com/iframe-page?filter=google" target="_parent">Google</a>

Once the parent page loads, it can set the IFRAME's URL based on it's own query string.

window.onload = function() { document.getElementById('myIframe').src = 'iframe.com' + location.search };
bdimag
  • 953
  • 8
  • 11
  • Maybe I'm not understanding and I apologize for that. Why do you have an anchor tag in your answer? I added the script you provided to my page but when I still access the page and utilize the filters I get nothing happening in the parent url – CrawlerWebSolutions Jun 30 '16 at 16:02
  • actually maybe I understand what you are suggesting. The anchor tag is within the iframe but the target has to be set to _parent within the iframe itself. – CrawlerWebSolutions Jun 30 '16 at 16:04
  • Correct, that way the link inside the IFRAME will control the parent page. – bdimag Jun 30 '16 at 16:08
  • Well this sucks... the backend of the iframe site has a bug that will not allow me to add the tag to the head of the site. Unfortunately I do it like this because there are around 300-500 links. – CrawlerWebSolutions Jun 30 '16 at 16:33