Solved

Frameset

Posted on 2009-07-05
22
259 Views
Last Modified: 2012-05-07
Hello,

I never worked with frames before.
I have a main page with frameset and it contain 3 frames.
Each frame is a diffrent page.
On page1 I have a button. If I click this button I need to display page4 in another frame.
How can I do it. I need to present something in diffrent page.

THANKS
Margarit
<frameset rows="64,*">
	<frame name="banner" src="Page1.html" target="contents">
	<frameset cols="215,*">
		<frame name="contents" src="Page2.html" target="main">
		<frame name="main" src="Page3.html">
	</frameset>
	<noframes>
	<body>

Open in new window

0
Comment
Question by:margarit
  • 12
  • 10
22 Comments
 
LVL 5

Expert Comment

by:Jagarm
ID: 24780777
You use the target properly of the link

so <a href="http://www.google.com" target="main">Google</a> this will display the page on main frame.

Let me know if it didn't work

Regards,
0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24780786
Note that target use the name of the frame and not the id. Yours is fine, but just so you know and avoid confusions
0
 

Author Comment

by:margarit
ID: 24812571
Hello,
THANKS for the comment.
But on what page should I set this function/event.
On page1.html where my button is located or on MainPage.html?
THANKS
Margarit
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 5

Expert Comment

by:Jagarm
ID: 24812649
On the button, can you show me how you are using the button to display the link, I'll let you know how you should do it.

Regards,
0
 

Author Comment

by:margarit
ID: 24812706
Hello,
Thanks again. I attach you the whole page which includes the button: MainManu_but_Image
Thanks
Margarit


<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 3</title>
<base target="main" />
<script type="text/javascript"> 
 
function presetImageMenu()
{
	alert ("kuku");
	<a href="\Image\ImageSetMenu.html" target="main">myTest</a>
}
</script>
 
</head>
 
<body >
 
<form method="post">
<p>
<input name="MainManu_but_Image" style="width: 171px" type="button" value="Image" onclick="presetImageMenu()"/></p>
</form>
</body>
 
</html>

Open in new window

0
 

Author Comment

by:margarit
ID: 24812718
Hi,
The previous file with the button was MainMenu2.html.
The current file, is a main page with frameset.
Thanks

<html>
 
<head>
<script type="text/javascript"> 
</script>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>Untitled 1</title>
</head>
 
<frameset rows="64,*">
	<frame name="banner" noresize="noresize" scrolling="no" src="MainMenu1.html" target="contents">
	<frameset cols="215,*">
		<frame name="contents" src="MainMenu2.html" target="main">
		<frame name="main" >
	</frameset>
	<noframes>
	<body>
 
	<p>This page uses frames, but your browser doesn&#39;t support them.</p>
 
	</body>
	</noframes>
</frameset>
 
</html>

Open in new window

0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24812797
The following is the javascript that you will use to display the link on the frame of your choice, simply replace frame_name with the name of your frame. So it's either contents or main.


<script type="text/javascript"> 
 
function presetImageMenu()
{
	window.frames["frame_name"].location.href = 'http://www.google.com';
}
</script>

Open in new window

0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24812868
If you have the button just to display a link, then you don't need to have it inside a form tag, the following does exactly the same thing


<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>Untitled 3</title>
<base target="main" />
</head>
 
<body >
 
 
<p>
<input name="MainManu_but_Image" style="width: 171px" type="button" value="Image" onclick="window.frames['new_frame'].location.href='http://www.google.com';"/>
</p>
 
 
</body
</html>

Open in new window

0
 

Author Comment

by:margarit
ID: 24812882
Hi,
Thanks!!!
Now it seems to enter the function it represet the alert on the screen.
But gives an error on :
window.frames["frame_name"].location.href = 'http://www.google.com';
The error says: "window.frames.main.location is null or not an object".
Does my frameset defined correctly?
THANKS a lot again!
0
 

Author Comment

by:margarit
ID: 24812891
I put it like this:
window.frames["main"].location.href = 'http://www.google.com';
 
0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24812900
You have to change frame_name with the name of the frame of your own:

So...
window.frames["contents"].location.href = "http://www.google.com" will display google on Page2.html of your original script.

0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24812909
Yes that way it will display on frame named "main" which is page3.html
0
 

Author Comment

by:margarit
ID: 24812952
Hello,
I get the same error :(
But I put attantion that I have a frameset inside a frameset. So maybe I have to call it in another way?
Thanks
 
0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24813012
Which frame do you want to display the link?

Please note that your frame must have a name, since it uses the name and not id,
0
 

Author Comment

by:margarit
ID: 24813083
I want to click the button on frame "contents" and display "ImageSetMenu.html" page on frame "main".
Main frame set is build from 3 parts:
"banner", "main", "contents"
"contents" present MainMenu2.html page - and its code located their.
"banner" present MainMenu1.html page
I need to click on button located on MainMenu2.html (that located in "contents") and see "ImageSetMenu.html" page in "main" frame
0
 

Author Comment

by:margarit
ID: 24813119
Hi,
I attach the screen shot

pic.JPG
0
 
LVL 5

Accepted Solution

by:
Jagarm earned 500 total points
ID: 24813128
Sorry about that, please use the following javascript, change window to top
<script type="text/javascript"> 
 
function presetImageMenu()
{
	top.frames['main'].location.href = 'http://www.google.com';
}
</script>

Open in new window

0
 

Author Comment

by:margarit
ID: 24813245
WOW!!!! It works!!!! Thanks a lot!
last question:
maybe you know a good example ?
Thanks
0
 

Author Comment

by:margarit
ID: 24813247
I meant good site with examples
0
 
LVL 5

Expert Comment

by:Jagarm
ID: 24813272
Do you mean good site example of frames?

Here is one: http://w3schools.com/html/html_frames.asp
0
 

Author Comment

by:margarit
ID: 24813661
Yes! Thanks!
0
 

Author Closing Comment

by:margarit
ID: 31599924
THANKS!!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Applications / Web Apps that enable highlighting text on Web Pages 3 30
Insert Button on a table 16 38
Html value of radio 14 31
Html Newline 7 21
This article discusses four methods for overlaying images in a container on a web page
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question