Blue Theme Orange Theme Green Theme Red Theme
 
Discover the top 5 tips for understanding .NET Interop
Home | Forums | Videos | Advertise | Certifications | Downloads | Blogs | Interviews | Jobs | Beginners | Training
 | Consulting  
Submit an Article Submit a Blog 
 Jump to
Skip Navigation Links
TechnologyExpand Technology
WebsiteExpand Website
Discover the top 5 tips for understanding .NET Interop
Search :       Advanced Search »
Home » ASP, JavaScript, CSS » Understanding Frames

Understanding Frames

Frames allow you to divide the page into several rectangular areas and to display a separate document in each rectangle.

Page Views : 2703
Downloads : 0
Rating :
 Rate it
Level : Beginner
   Print Read/Post comments Post a comment  Similar Articles  
   Email to a friend  Bookmark  Author's other articles  
 
Discover the top 5 tips for understanding .NET Interop
Become a Sponsor
 Tag Cloud
 Latest Jobs
More ... 
 Latest Interview Questions
More ... 


Frames

 

Frames allow you to divide the page into several rectangular areas and to display a separate document in each rectangle. Each of those rectangles is called a "frame".

 

Here is an example:

<FRAMESET ROWS="75%, *" COLS="*, 40%">
  <FRAME SRC="framea.html">
  <FRAME SRC="frameb.html">
  <FRAME SRC="framec.html">
  <FRAME SRC="framed.html">
  <NOFRAMES>
  <H1>No Frames? No Problem!</H1>
  Take a look at our
  <A HREF="noframes.html">no-frames</A>
  version.
  </NOFRAMES> 
</FRAMESET> 

1         <FRAMESET ...> is used instead of the <BODY ...> tag. The frameset file has no content which appears on the page, so it has no need for <BODY ...>, which designates the content of the page. In fact, if you use <BODY ...> (except inside <NOFRAMES>), the frames will not appear. Tags in <HEAD>, including <TITLE>, still have their intended effects.

2         Rows and columns are described by a list of widths or heights. For example COLS="25%, *, 40%" says that there will be three columns. The first column takes up 25% of the width of the page, the third column takes up 40% of the width of the page, and the asterisk ("*") means "whatever is left over". See COLS and ROWS for more details.

Nested Frames 
<FRAMESET ROWS="15%,*">
   <FRAME SRC="titlebar.html" NAME=TITLE SCROLLING=NO>
   <FRAMESET COLS="20%,*">
      <FRAME SRC="sidebar.html" NAME=SIDEBAR>
      <FRAME SRC="menu.html" NAME=RECIPES>
   </FRAMESET> 
   <NOFRAMES>
      No frames? No Problem! Take a look at our
   <A HREF="menu.html">no-frames</A> version.
   </NOFRAMES> 
</FRAMESET> 
Targeting Frames 
Each frame is given a name using <FRAME NAME="...">. These names uniquely identify each frame. Using these names, links in other frames can tell the browser which frame the link targets.

 

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

 

To target one of these frames, the link should have a TARGET attribute set to the name of the frame where the linked page should appear. So, for example, this code creates a link to tfetacos.html and targets that link to the MAIN frame:

 

<A HREF="tfetacos.html" TARGET=MAIN>my link</A>

 

Targeting the whole window

 
Eventually in a framed site you want to "break out"... link to a page and have that page take over the entire window. To create this sort of link, we add TARGET="_top" to the <A ...> tag:

<A HREF="wwtarget.html" TARGET="_top">

 

"_top" is a reserved name which is automatically given to the entire window

 

No Frames

 

Browsers that know frames will ignore everything between <NOFRAMES> and </NOFRAMES>. Browsers that don't understand frames will also not understand (and therefore ignore) <NOFRAMES>, and display the content

 
To create a borderless frameset, use a <FRAMESET ...> tag with FRAMEBORDER, FRAMESPACING, and BORDER attributes like this:

<FRAMESET ROWS="20%,*" FRAMEBORDER=NO FRAMESPACING=0 BORDER=0>

 

Restrict our page from iframe

 

If you don't want your page to be framed, put this little Javascript in the page:

 

<SCRIPT TYPE="text/javascript">

<!--

if (top != self)

     top.location=self.document.location;

//-->

</SCRIPT>

 

This script checks to see if the current page is the "top" page. If it is not, it tells the web browser to load the current web page as the top, thus wiping out any frames.

 

Always our page to be framed

 

Sometimes a particular web page only makes sense if it appears in a frame.

 

<SCRIPT TYPE="text/javascript">

<!--

function checkframed(url)

{

if (top == self)

   document.write(

      '<DIV STYLE="padding:8pt;' +

      'border-style:solid;border-width:8pt;' +

      'border-color:66CC33;">' +

      '<STRONG>' +

      'This page is intended as part of a ' +

      '<A HREF="' + url + '">framed document</A>.' +

      '</STRONG></DIV>');

}

 

checkframed("dgftop.html");

 

//-->

</SCRIPT>

 

FRAME Attributes 

FRAMEBORDER = YES | 1 | NO | 0
FRAMESPACING = integer
BORDER = integer

COLS = integer
ROWS = integer

BORDERCOLOR = color expression

SRC = "URL"

NAME = "text string"

SCROLLING = YES | NO | AUTO

NORESIZE says that the user cannot make the frame bigger or smaller by sliding the borders

FRAMEBORDER = YES | 1 | NO | 0

 

 

 

Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post Here.
Login to add your contents and source code to this article
 [Top] Rate this article
 
 About the author
 
Dhana Lakshmi
Looking for C# Consulting?
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional consulting company, our consultants are well-known experts in .NET and many of them are MVPs, authors, and trainers. We specialize in Microsoft .NET development and utilize Agile Development and Extreme Programming practices to provide fast pace quick turnaround results. Our software development model is a mix of Agile Development, traditional SDLC, and Waterfall models.
Click here to learn more about C# Consulting.
 
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
Discover the Top 5 .NET Memory Management Fundamentals
To write the best .NET code, you need to know exactly how the .NET framework really manages memory. Ricky Leeks presents the Top 5 fundamental facts of .NET memory management. Learn more.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
 
 Post a Feedback, Comment, or Question about this article
Subject:
Comment:
Nevron Chart
Become a Sponsor
 Comments
Team Foundation Server Hosting
 © 2012  contents copyright of their authors. Rest everything copyright Mindcracker. All rights reserved.