PDA

View Full Version : Target a frame using <iframe>



tacbob
09-28-2004, 11:41 AM
Is it possible to href from a button to open a page in a targeted frame?

I have several buttons that I want to use this command on so that different pages open up in the same frame that has an id?

Thank you

gigabites
09-28-2004, 02:23 PM
<iframe src="main_page.html" name="myframe"></iframe>
<br><br>
<input type="button" value="links" onclick="myframe.location.href='links_page.htm'">
<input type="button" value="guestbook" onclick="myframe.location.href='guestbook.htm'">
<input type="button" value="pictures" onclick="myframe.location.href='pictures.htm'">I hope that helps :)

tacbob
09-28-2004, 03:23 PM
I do not understand where I put the following code:

<input type="button" value="links" onclick="myframe.location.href='links_page.htm>


Also, what if I need to define the size of the iframe and scroll it?

Thanks

cr3ative
09-28-2004, 07:14 PM
Right, i'll break gigabites' script down:

<iframe src="main_page.html" name="myframe"></iframe>

These are your Iframe parameters, you can define the sizes in this line (width=90, height=90), and scrollbars=true (?)

<br><br>

Leaves a couple of lines

<input type="button" value="links" onclick="myframe.location.href='links_page.htm'">

Changes iframe location to links_page.htm

<input type="button" value="guestbook" onclick="myframe.location.href='guestbook.htm'">

Changes iframe location to guestbook.htm

<input type="button" value="pictures" onclick="myframe.location.href='pictures.htm'">

Changes iframe location to pictures.htm


Hope this helps
cr3ative

gigabites
09-28-2004, 09:39 PM
@tacob
Simply put that code in the page where You want the buttons (and the iframe) to appear.

If You want a 400 x 400 iframe with no scrollbars...

<iframe src="main_page.html" name="myframe" width="500" height="500" scrolling="no"></iframe>

@cr3ative
it's scrolling="no"... I couldn't have known it without My manual though :D