How would I encode a URL on home.htm to open another page (index1.htm) which contains an Iframe with name="test" and id="test" and load it with include1.htm or include2.htm which resides in the same directory as index1.htm.
------------------------
Example: (button 1 needs encoding)
home.htm -> button 1 -> links to index1.htm
Index1.htm -> iframe name and id="test"
iframe "test" -> displays one of two includes as defined by button 1 encoding
You can do this easily with a querystring that passes the URL to load as follows:
First, add JavaScript to the header of index1.htm:
(note that
test is the name/id of your iframe element)
<script type="text/javascript">
function loadIframe()
{
var urlStr;
urlStr = location.search.slice(1);
window.frames.test.location = urlStr;
}
</script>
Next, call the function in the body onload:
<body onLoad="loadIframe()">
Then, in the home page, make links that use a querystring to pass the info:
<a href="index1.htm?page1.htm">Page 1</a>
<a href="index1.htm?page2.htm">Page 2</a>
Now, the links go to the page with the iframe, the function parses out the page passed by the query string, and sets the src of the text iframe with it. You can just have src="" on the page, as it's going to get reset anyway.
-Skarjune