By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,168 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,168 IT Pros & Developers. It's quick & easy.

Call to page and load IFRAME

P: 2
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
Oct 27 '06 #1
Share this Question
Share on Google+
3 Replies


P: 2
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 (load variables by url or javascript) 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
Oct 27 '06 #2

P: 1
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
Nov 17 '06 #3

P: 1
My use of this is slightly different than Dennis'. I'm using the iframe as the main content area on index.php. and i'ts working well for loading specified content from the url [ www.mysite.com/index.php?content.php ]

However when i just go to "www.mysite.com" the onLoad function loops and loads a bunch of index.php pages in my iframe.

How can I make it default to loading "home.php" into the iframe unless there is a query present in the url string?
Aug 20 '10 #4

Post your reply

Sign in to post your reply or Sign up for a free account.