-1

So this is my situation; I have a page that shows data from an xml. This page generates links dynamically based on the data it receives. Right now when I click these links, it opens a new tab/window with exactly what it needs to show.

However...

My problem: I need this to work slightly differently. I need these links to open in an iFrame inside a fixed page... What do I mean..? This should explain better

Page1 has many links with different URLs (generated by xml)

Page2 has a fixed url (like... http://www.dummysite.com/instructions). The lay out is a set of text instructions and an iFrame

When the user clicks a link in Page1, what needs to happen is: Page2 opens up with it's fixed url and the link the user clicked on (the XML generated link) opens up inside the iframe of Page2

I really don't know how to better explain this, and I don't even know what to search for answers.

Help me oh wise people of the internet, you're my only hope

Rodrigo Viola
  • 11
  • 1
  • 6
  • Do you have access to the link generator for Page 1? In other words, are you able to modify the generated links to redirect the user to your page 2? – Miro Markaravanes Jul 11 '16 at 19:01
  • [This question](http://stackoverflow.com/questions/6000987/dynamically-set-iframe-src) might help point you in the right direction – spaniol6 Jul 11 '16 at 19:02
  • When you link to page 2 can you put the XML link in the query string? ie: `http://me.com/pagetwo.html?link=http%3A%2F%2Fme.com%2FpageOne.html` and then have a script on page two that reads that and opens it up? – jmbmage Jul 11 '16 at 19:02
  • @jmb.mage I will try this approach as it seems totally doable. Thanks man! – Rodrigo Viola Jul 11 '16 at 19:20

1 Answers1

0

To access an iframe that has the id "myIframe" in a a window you can use

var iframe = wnd.document.getElementById('myIframe')

To change its scr You can use iframe.src = url;

var wnd= window.open("", "", "width=400,height=400");
wnd.document.write('<iframe id="myIframe"src="https://bing.com" />');
wnd.document.getElementById('myIframe').src ="https://www.bing.com/search?q=cats";
Kld
  • 6,970
  • 3
  • 37
  • 50