+ Reply to Thread
Results 1 to 7 of 7

Thread: Working with IFRAMES

  1. #1
    james70 is offline x10Hosting Member james70 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    6

    Working with IFRAMES

    I have a page with an IFRAME that points to another site. is there a way to create a link on a sperate page that would open the page with the IFRAME but change the content of the IFRAME?

  2. #2
    wongers's Avatar
    wongers is offline x10 Lieutenant wongers is an unknown quantity at this point
    Join Date
    Nov 2009
    Location
    Leeds, England
    Posts
    432

    Re: Working with IFRAMES

    i think your referring to:
    <a href="http://url.here" target="iFrame_name">Link</a>

    from what you've described, you need the target="***" bit. the *** being the name of your iFrame.

    if this isnt what your after, let me know and we'll discuss it :-)

  3. #3
    james70 is offline x10Hosting Member james70 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    6

    Re: Working with IFRAMES

    That's not really what I'm looking for. That works if the link and the frame are in the same .html file. Let me try to explain better. say I have a home.html file and a store.html file. The store.html has the frame that defaults to the store index page. I wnt to put a link on the home.html that points to the store.html but changes the content of the frame form the index page to a spacific product page.

  4. #4
    descalzo's Avatar
    descalzo is offline Grim Squeaker descalzo has a brilliant futuredescalzo has a brilliant futuredescalzo has a brilliant future
    Join Date
    Jul 2009
    Location
    Ankh-Morpork
    Posts
    7,636

    Re: Working with IFRAMES

    You can do it with .php files.

    links:

    store.php?q=apples
    store.php?q= cherries

    store.php puts out basically the same html it does now, just adjusting the src attribute in the IFRAME tag.

    PHP Code:

    <?php 
       
    if( isset( $_GET['q'] ) ){
             
    $src $_GET['q'] . ".html" ;
       } else {
             
    $src "default_product.html" ;
       }
    ?>

    <iframe src="<?php echo $src ?>" width="100%" height="300">
      <p>Your browser does not support iframes.</p>
    </iframe>
    Nothing is always absolutely so.

  5. #5
    LostHorizon's Avatar
    LostHorizon is offline x10Hosting Member LostHorizon is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    35

    Re: Working with IFRAMES

    Hi "james70",

    If you want to use just HTML and JavaScript for your codes, try the followings:
    1. First, in your "home.html" HTML document, use "?url=some product.html" (it DOESN'T have to be "url=some product.html" specifically - I just use it as an example) in the HTML <A> tag after the link ("store.html") to pass the URL of the page that you want to show in your "store.html"'s <IFRAME> to the "store.html" HTML document,

      Code:
      <A href = "store.html?url=some product.html"></A>
    2. Second, in your "store.html" HTML document, use JavaScript to parse the "window.location.href"'s (or more specifically, "window.location.search" - don't know if this attribute/property is available in other browsers besides Microsoft Internet Explorer or not) result string to fetch the passed URL and feed it to the page's <IFRAME>'s src (let me know if you need further help on this).
    Hope this helps.
    Website: http://losthorizon.cz.cc/

    "Genius is one percent inspiration and ninety-nine percent perspiration" -- Thomas Alva Edison.

  6. #6
    james70 is offline x10Hosting Member james70 is an unknown quantity at this point
    Join Date
    May 2011
    Posts
    6

    Re: Working with IFRAMES

    Thanks. you've been a lot of help.
    Below is the code I ended up using:

    <iframe src="http://defaultpage" width="100%" height="850" id="inframe">
    <p>Your browser does not support iframes.</p>
    </iframe>

    <script language="javascript" type="text/javascript">
    var query = window.location.href.split("?");
    var params = query[1].split("url=");
    document.getElementById('inframe').src = params[1];
    </script>


    Link: <a href="http://mysite/?url=http://storesite/page">LINK</a>

    I hope this helps someone else.

  7. #7
    LostHorizon's Avatar
    LostHorizon is offline x10Hosting Member LostHorizon is an unknown quantity at this point
    Join Date
    Dec 2010
    Posts
    35

    Re: Working with IFRAMES

    Nicely done "james70",

    Also, it's very NICE of you (very COMMENDABLE) to present the solution here as well so others can benefit from it.
    Website: http://losthorizon.cz.cc/

    "Genius is one percent inspiration and ninety-nine percent perspiration" -- Thomas Alva Edison.

+ Reply to Thread

Similar Threads

  1. Iframes
    By icedhabbo in forum Programming Help
    Replies: 21
    Last Post: 08-11-2011, 08:11 PM
  2. iframes
    By allinone in forum Programming Help
    Replies: 4
    Last Post: 07-20-2008, 10:09 AM
  3. iFrames
    By Jacob, Kid Mania Creator in forum Crossfire
    Replies: 14
    Last Post: 02-02-2008, 10:43 AM
  4. [REQ] Iframes
    By Derek in forum The Marketplace
    Replies: 4
    Last Post: 01-25-2007, 05:03 PM
  5. iFrames
    By SEŅOR in forum Free Hosting
    Replies: 3
    Last Post: 06-02-2006, 05:36 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers