can iframe be selected from parent window url?

Is there any way for a single url to select both a parent page and the src value (url) of a page to appear within iframe tags in the parent page?
Jonathan GreenbergAsked:
Who is Participating?
 
Michel PlungjanIT ExpertCommented:
Yes

<a  href="http://www.yourserver.com/index.html?iframe=iframe1&url=iframe_page.html">Load index and iframe</a>


This will load the page iframe_page.html into the iframe called iframe1 when the page is loaded from the link
<html>
<head>
<script>
var loc = location.search;
if (loc) loc = loc.split("&");
window.onload=function() {
  if (loc) {
    var iframeName=loc[0].split("=")[1];
    var page=loc[1].split("=")[1];
    window.frames[iframeName].location=page;
  }
}
</script>
</head>
<body>
.
.
.
<iframe name="iframe1" src="about:blank"></iframe>
</body>
</html>

Open in new window

0
 
Jonathan GreenbergAuthor Commented:
Thanks.

I'm assuming your code is index.html in your example. I've copied and pasted your code, and I've reproduced your exact example, but all I get is the parent page with an empty iframe.
0
 
Jonathan GreenbergAuthor Commented:
No, I'm sorry, my mistake! It works perfectly. Thanks!
0
 
Jonathan GreenbergAuthor Commented:
Thanks for the great answer.
0
 
Michel PlungjanIT ExpertCommented:
YW :)
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.

All Courses

From novice to tech pro — start learning today.