Call to page and load IFRAME

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dennis Sirois
    New Member
    • Oct 2006
    • 2

    Call to page and load IFRAME

    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
  • Dennis Sirois
    New Member
    • Oct 2006
    • 2

    #2
    Call to page and load IFRAME

    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

    Comment

    • skarjune
      New Member
      • Nov 2006
      • 1

      #3
      Originally posted by Dennis Sirois
      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.t est.location = urlStr;
      }
      </script>

      Next, call the function in the body onload:

      <body onLoad="loadIfr ame()">

      Then, in the home page, make links that use a querystring to pass the info:

      <a href="index1.ht m?page1.htm">Pa ge 1</a>
      <a href="index1.ht m?page2.htm">Pa ge 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

      Comment

      • revata
        New Member
        • Aug 2010
        • 1

        #4
        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?

        Comment

        Working...