+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: iframe help

  1. #1
    PacersForever is offline x10Hosting Member PacersForever is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    21

    iframe help

    Is it possible to have buttons that change the iframe on your site ? Diagram below.



  2. #2
    marshian's Avatar
    marshian is offline x10 Elder marshian is an unknown quantity at this point
    Join Date
    Jan 2008
    Location
    Belgium
    Posts
    526

    Re: iframe help

    Yes.






    Obviously I'll give some more info than just "Yes.", but that's all you asked for :p
    It's actually quite easy, a normal <a> tag looks like this:
    HTML Code:
    <a href="http://forums.x10hosting.com/programming-help/url">
    But there's a parameter "target" too:
    HTML Code:
    <a href="http://forums.x10hosting.com/programming-help/url" target="name">
    This would open the link in the frame (iframe / frameset) named "name".
    eg.
    HTML Code:
    <a href="http://www.google.com" target="frame">Google in frame.</a>
    <iframe name="frame" />
    Last edited by marshian; 08-31-2008 at 09:38 AM. Reason: htt -> http
    Real programmers don't document their code - if it was hard to write, it should be hard to understand.

  3. #3
    PacersForever is offline x10Hosting Member PacersForever is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    21

    Re: iframe help

    Thanks !!! But it doesn't work with firefox
    Firefox doesn't know how to open this address, because the protocol (htt) isn't associated with any program.

  4. #4
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: iframe help

    that's a typo in the example by marshian. Add a 'p' into the link so it reads:
    HTML Code:
    <a href="http://www.google.com" target="frame">Google in frame.</a>
    <iframe name="frame" />
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  5. #5
    scopey is offline x10Hosting Member scopey is an unknown quantity at this point
    Join Date
    May 2008
    Posts
    62

    Re: iframe help

    Or you could JS it.

    HTML Code:
    <button onclick="document.getElementById('frame').src = 'http://www.google.com';">Google.com</button>
    <iframe id='frame' />
    - When in doubt, refer to the PHP manual.

  6. #6
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: iframe help

    Quote Originally Posted by scopey View Post
    Or you could JS it.

    HTML Code:
    <button onclick="document.getElementById('frame').src = 'http://www.google.com';">Google.com</button>
    <iframe id='frame' />
    JS is good for this. However, make sure you use the following to ensure that it will work for more people:
    HTML Code:
    <script type='text/javascript>
       document.write ("<button onclick=\"document.getElementById('frame').src = 'http://www.google.com';\">Google.com</button>");
    </script>
    <noscript>
       <a href="http://www.google.com" target="frame">Google in frame.</a>
    </noscript>
    
    <iframe name='frame' id='frame'>
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  7. #7
    PacersForever is offline x10Hosting Member PacersForever is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    21

    Re: iframe help

    Ok I have this now

    PHP Code:
    <a href="http://www.nba.com" target="frame">NBA</a>
    </
    noscript>

    <
    a href="http://www.google.com" target="frame">Google in frame.</a>
    </
    noscript>

    </
    p>
    <
    script type='text/javascript>
       document.write ("<button onclick=\"document.getElementById('
    frame').src = 'http://www.google.com';\">Google.com</button>");
    </script>
    <noscript>
       <a href="http://www.google.com" target="frame">Google in frame.</a>
    </noscript>

    <iframe name='frame' id='frame'> 

    Is there a way to make the links buttons and for it to automatically open in one of the links ?
    Last edited by PacersForever; 08-31-2008 at 02:06 PM.

  8. #8
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: iframe help

    Quote Originally Posted by PacersForever View Post
    Is there a way to make the links buttons and for it to automatically open in one of the links ?
    I'm not quite sure what you mean there...?
    If you use the following code, it will make all your links buttons, and pressing a button will change the frame, depending on which button was pressed.
    HTML Code:
    <p>
    <script type='text/javascript'>
      document.write ("<button onclick=\"document.getElementById('frame').src = 'http://www.google.com';\">Google</button>");  
      document.write ("<button onclick=\"document.getElementById('frame').src = 'http://www.nba.com';\">NBA</button>");
      </script>
    <noscript>
      <a href="http://www.google.com" target="frame">Google</a> <a href="http://www.nba.com" target="frame">NBA</a>
    <button onclick="document.getElementById('frame').src = 'http://www.google.com';">Google</button>
    </noscript>
    </p>
    <iframe name='frame' id='frame' width='600' height='500'></iframe>
    However, because the button needs JavaScript in order to work, the <noscript> section cannot use buttons unless you also use PHP or another server side language to refresh the page with the iframe loaded.
    The iframe has a size of 600x500. Change this to whatever you want it to be.

    In short, that will show buttons for most people, and text links for people that do not have JavaScript enabled on their browser.
    You can add new links by copying the existing ones and modifying them to point to the new locations and so forth.



    ...Also, I've removed bugs and typos that have accumulated through different people helping you. It is HTML, not XHTML. If you know what I'm going on about, change it if you prefer. If you don't, then it will be fine as it is.
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  9. #9
    PacersForever is offline x10Hosting Member PacersForever is an unknown quantity at this point
    Join Date
    Aug 2008
    Posts
    21

    Re: iframe help

    Thanks man thats exactly what i was looking for. Is there a possibility for one of them to automatically open once you run the code ?

  10. #10
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: iframe help

    Of course!
    Change the last line into something like this:
    HTML Code:
    <iframe name='frame' id='frame' width='600' height='500' src='http://www.google.com'></iframe>
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Iframe not transperent in ie 6!
    By Teensweb in forum Programming Help
    Replies: 5
    Last Post: 02-07-2009, 10:06 AM
  2. iframe javascript problem
    By oracle in forum Programming Help
    Replies: 5
    Last Post: 06-29-2008, 12:56 PM
  3. Passing vars from parent to iframe
    By gottaloveit in forum Programming Help
    Replies: 8
    Last Post: 05-07-2008, 11:15 AM
  4. just how smart can an iframe get?
    By bonzo meier in forum Programming Help
    Replies: 4
    Last Post: 03-05-2008, 10:58 AM
  5. Iframe
    By galaxyAbstractor in forum Graphics & Webdesign
    Replies: 2
    Last Post: 02-19-2008, 03:57 PM

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