View Full Version : Need to load only the iFrame content with new URL
SaltyFoam
Mar 25th 2008, 4:03 pm
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>
Morishani
Mar 26th 2008, 12:04 am
delete parent in the "onclick" event, so it will be like that :
<button onclick="location='http://mydomain/..'">Go There</button>
But I wouldn't recommend you use buttons as links because it is not semantic.
budster
Mar 31st 2008, 4:09 am
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
sandeepb
Apr 2nd 2008, 9:59 am
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'"
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.