Solved

can iframe be selected from parent window url?

Posted on 2011-02-16
5
276 Views
Last Modified: 2012-05-11
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?
0
Comment
Question by:Jonathan Greenberg
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 34908929
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
 

Author Comment

by:Jonathan Greenberg
ID: 34909302
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
 

Author Comment

by:Jonathan Greenberg
ID: 34909405
No, I'm sorry, my mistake! It works perfectly. Thanks!
0
 

Author Closing Comment

by:Jonathan Greenberg
ID: 34909488
Thanks for the great answer.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 34909546
YW :)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now