
Originally Posted by
some guy named Kevin
This quote is hidden because you are
ignoring this member.
Show
Make a container file -- we'll call it container.htm in this example -- that contains an iframe named "iframe1". This is the remote page/iframe that will be used to contain the intended content pages. The name of the page to load into the iframe is passed as a parameter to container.htm, in a url string (e.g., ?pagename.htm). container.htm defines a small javascript function, called loadIframe(), that parses the query string and loads the specified page into the into the iframe. The loadIframe() function is called from the onload event of the <body> tag in container.htm. The basic html in container.htm would look something like this:
Code:
<html>
<head>
<script type="text/javascript">
function loadIframe()
{
var urlStr;
urlStr = location.search.slice(1);
window.frames.iframe1.location = urlStr;
}
</script>
</head>
<body onload = "loadIframe()">
<h3>I am the "remote" container window with the iframe</h3>
<br>
<iframe name="iframe1" id="iframe1" frameborder="1" width="750" height="200" marginwidth="20" marginheight="10" scrolling="auto"> </iframe>
</body>
</html>
Note the definition of the loadIframe() function in the <head> of container.htm.
The url property is like so: url=container.htm?contentpage.htm;... where contentpage.htm is the name of the file you want to load into the iframe.
This way, you have only one page with an iframe to worry about, and any other page can be loaded into it. A similar approach could be taken for a container page with multiple iframes, but then you'd have to pass and parse a more complex query string including iframe names and page names (like ?frame1=page1.htm&frame2=page2.htm... etc). A little more complex, but do-able.