1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Need to load only the iFrame content with new URL

Discussion in 'JavaScript' started by SaltyFoam, Mar 25, 2008.

  1. #1
    I have an iFrame that contains some Web pages. I can use regular <A> links or forms to switch between the pages inside the iFrame. I want to have a button that when clicked does the same thing... loads the iFrame with a different page. I tried the following but it loads the new page into the whole browser page, not just the iFrame:

    <BUTTON TYPE="button" onClick="parent.location='http://MyDomain/MyNewPage'">Go There</BUTTON>
     
    SaltyFoam, Mar 25, 2008 IP
  2. Morishani

    Morishani Peon

    Messages:
    239
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #2
    delete parent in the "onclick" event, so it will be like that :
    
    <button onclick="location='http://mydomain/..'">Go There</button>
    
    HTML:
    But I wouldn't recommend you use buttons as links because it is not semantic.
     
    Morishani, Mar 26, 2008 IP
  3. budster

    budster Peon

    Messages:
    18
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    The target= parameter may be what you're after. If you give the iframe a name, then reference the name in the call to the new page
    EG: <iframe name="myiframe".... <a hef=.... target="myiframe"....

    Hope this helps
     
    budster, Mar 31, 2008 IP
  4. sandeepb

    sandeepb Peon

    Messages:
    109
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    budster is right,

    If you have the name in the iframe.... <iframe name="frame1"...

    Then your function will be:

    onclick="frame1.location='http://page.html'"
     
    sandeepb, Apr 2, 2008 IP