Results 1 to 2 of 2

Thread: Iframe Links

  1. #1
    Join Date
    Mar 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Iframe Links

    On my latest project, I have links and an iframe. What I initially want is to have the links open within the iframe. Also, if it is possible, I want the links to be anchored to specific points on the page that will be opened in the iframe.

    To be more specific, I have one page (A) and another page (B). Page (A) contains an iframe that displays page (B). Page (A) contains photos of people and their names, displayed in basic text. Their names will be the links. Page (B) contains those people's biographies. What I want to be able to do is click on a person's name, and have the iframe open to that specific person's biography.

    How, if possible, can I do this? I can't seem to pull it off.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    First of all, give your iframe a name attribute, ex:

    Code:
    <iframe name="myiframe" src="whatever.htm" width=" . . . ></iframe>
    When you link to the iframe from the top page use:

    Code:
    <a href="whatever.htm#bob" target="myiframe">Bob Peabody</a>
    Notice the blue part of the href, that is known as the hash because it starts with a hash (#) mark. That tells the browser which named anchor in the linked page to scroll to. So, for our example link, you could have this named anchor just above Bob Peabody's section on whatever.htm:

    Code:
    <a name="bob"></a>
    Last edited by jscheuer1; 03-30-2007 at 01:32 PM. Reason: Update Info
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

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
  •