Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Iframe help: Can not find solution ANYWHERE :(

  1. #1
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Iframe help: Can not find solution ANYWHERE :(

    I've seen this question asked on several forums yet the answer has never been provided with clarity...

    In short, I have a home page, and different page with an iframe. I need links on my homepage to open the page with the iframe on it, and i need each link to open a unique(different) site in that iframe...

    Specifically, I have two pages, index.htm and nba_main.htm... nba_main.htm has an iframe on it... index.htm has a menu with about 10 links ALL pointing to nba_main.htm, but I need those links to display a different page each time in the Iframe... So 10 links on index.htm going to nba_main.htm, but I need the links to be different in that they will open different pages within the iframe on nba_main.htm...

    Example I

    1. Someone visits index.htm and clicks on the "matchups and scores" button.
    2. nba_main.htm comes up in the same browser with "matchups.htm" within the iframe window

    Example II

    1. Someone visits index.htm and clicks on the "live odds" button.
    2. nba_main.htm comes up in the same broswer with "latestodds.htm" within the iframe window


    I've been trying to tackle this all week and I would DEEPLY appreciate any help with this!
    Last edited by StivenUSB; 09-22-2007 at 05:26 PM. Reason: added examples

  2. #2
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am beginning to think that this is not even possible... Please if anyone can help me out or if you'd like a better-explained description of what I am trying to do let me know... This is really holding up my site design

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    You can do this with PHP (maybe javascript too, but I'd recommend PHP for several reasons-- easier, and it wouldn't require the user have Javascript enabled).

    Note that to use PHP, you must have the extension of the page be .php, not .htm (unless you change your server configuration), as well as having PHP installed/enabled on the server.

    Use a get variable to pass the link:
    <a href="nba_main.php?iframe=http://othersite.com">

    On nba_main.php:
    Code:
    <iframe src="<?php echo $_GET['iframe']; ?>" ....>
    Now, you may also want to do a bit more to check that it is in fact a link you want to use like that, not just something the user entered randomly.
    Code:
    <?php
    $iframe = @$_GET['iframe'];
    $okurls = array(
    'http://1.com',
    'http://2.com',
    'http://3.com'
    );
    if (!in_array($iframe,$okurls)) { $iframe = 'http://default.com'; }
    ?>
    Then just use <?php echo $iframe; ?> for the iframe's src.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok, so on index.php I have a menu with a link, the link is <a href="nba_main.php?iframe=http://affstats.betus.com/NBA/matchups.aspx?ats=10468&mid=797">

    On nba_main.php, I have an iframe, the spot where I want the iframe to show has this code: <iframe name="iframe" src="<?php echo $_GET['iframe']; ?>" height="800" width="500"></iframe>

    And it is not working... I am not very php-inclined so I may be running into an obvious mistake... Shouldn't I have a php include in there somewhere or am I running into a different problem?

    Thank you very much for your help...

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    include() is just one function used in PHP. Not related in this case.

    Link to your page. What's the problem? what IS the src of the page displayed as?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    On the main page, scroll over nba and a menu will drop down... On the drop down, when you click matchups it should take you to nba_main.php with the matchups page loaded in the iframe...

    this is going to be the main page: www.ultimatesportsbets.com/scrap.php

    this is nba_main.php:
    http://www.ultimatesportsbets.com/nba_main.php

    Thanks again...

    BTW... Disregard all of the other links as I am only using the nba:matchups link for testing purposes...

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Ok, I get it.

    The issue is that the URL isn't being used fully.

    The url you're using for the iframe has get variables of its own, so that confuses the browser:
    http://1.com?iframe=http://2.com?a=b, etc.

    So, you'll want to encode the link for a url.

    Easiest way is with PHP:
    <a href="<?php echo urlencode('http://whatever.com?variable=value&etc.'); ?>">

    That will change symbols and spaces to their correct codes, ie %20 for space.


    You could also use a different code, like
    ?page=a

    then use an array like:
    array('a'=>'http://a.com'), and $that['a'] will give you 'http://a.com'.
    So you don't need to send the full URL, just the reference for that link. Takes a bit more setup, but easier to remember/use the URLs.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    So my link should be looking something like this?
    <a href="<?php echo urlencode('http://www.ultimatesportsbets.com/nba_main.php?iframe=http://affstats.betus.com/NBA/matchups.aspx?ats=10468&mid=797'); ?>">

    I apologize for my ignorance with using php :\

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Yep. Looks right.
    Or you could manually change the link to a url supported format, but that would be hard unless you happen to have it memorized.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    Feb 2007
    Location
    Michigan
    Posts
    15
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried it and it gives me a 404 error I am completely out of luck with trying to get this done... :-\

    The error can be seen by visiting the above links again or... http://www.ultimatesportsbets.com/scrap.php

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •