Button to open html doc in different frame

M

mervin

Hello;

I am brand new to Javascript.
For a frameset html page: How do I get my navigation buttons (in a
separate frame at left) to open an html document in a different
frame? I have unsuccessfully experimented with
onClick="jumpto2 ......",

I need to get the button to go to a different frame and html document,
and also to an html anchor in that document.

I'm having a bit of trouble getting info on this, and thank you for
any help.

Thanks;

Bob Donaldson
 
D

Doug Gunnoe

Hello;

I am brand new to Javascript.
For a frameset html page: How do I get my navigation buttons (in a
separate frame at left) to open an html document in a different
frame? I have unsuccessfully experimented with
onClick="jumpto2 ......",

I need to get the button to go to a different frame and html document,
and also to an html anchor in that document.

I'm having a bit of trouble getting info on this, and thank you for
any help.

Thanks;

Bob Donaldson

if just a hyperlink, all you got to do is use the target attribute
like so, where MAIN is the frame you're after.

<a href="somepage.html" target=MAIN>

Anyway, here is what I came up with for buttons. The following is in
the left sidebar in my example.

<html>
<head>
<script>
var mainFrame;
function getMainFrame(){
mainFrame = parent.document.getElementById('main');
}

function loadPage(myURL){
mainFrame.src = myURL;
}

</script>
</head>

<body onload="getMainFrame();">

<input type="button" onclick="loadPage('http://google.com');"
value="Click me" />

</body>

</html>

and in the frameset, give the frame an id of 'main'

<FRAMESET COLS="20%,*">
<FRAME SRC="test1.html" NAME=SIDEBAR>
<FRAME id="main" SRC="test2.html" NAME=MAIN>
</FRAMESET>


Probably easier way to do this, but at any rate, get an object
reference to the frame you want and then set the src attribute.

Hope that helps and good luck.
 
B

bobd

if just a hyperlink, all you got to do is use the target attribute
like so, where MAIN is the frame you're after.

<a href="somepage.html" target=MAIN>

Anyway, here is what I came up with for buttons. The following is in
the left sidebar in my example.

<html>
<head>
<script>
var mainFrame;
function getMainFrame(){
mainFrame = parent.document.getElementById('main');

}

function loadPage(myURL){
mainFrame.src = myURL;

}

</script>
</head>

<body onload="getMainFrame();">

<input type="button" onclick="loadPage('http://google.com');"
value="Click me" />

</body>

</html>

and in the frameset, give the frame an id of 'main'

<FRAMESET COLS="20%,*">
      <FRAME SRC="test1.html" NAME=SIDEBAR>
      <FRAME id="main" SRC="test2.html" NAME=MAIN>
   </FRAMESET>

Probably easier way to do this, but at any rate, get an object
reference to the frame you want and then set the src attribute.

Hope that helps and good luck.- Hide quoted text -

- Show quoted text -

Thank you very much for your help, Doug.

Sincerely;

Bob Donaldson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,226
Latest member
KristanTal

Latest Threads

Top