Results 1 to 7 of 7

Thread: frames

  1. #1
    Join Date
    Dec 2004
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default frames

    is there way to keep a page inside a frame if it has a code that breaks the frame?

  2. #2
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sure, you can put in an include statement in the head of your page that references another page (we'll call 'checkforframes.aspx') and passes the name of the page via querystring. The page 'checkforframes.aspx' can check to see if it is the top frame using javascript "if (top == self)". If the page is the top frame, then pass the name of the page from querystring to your frames.aspx page using querystring again so that it is embedded into a frameset. If 'checkforframes.aspx' determines that your page is not the top frame, then it returns silently back to your application.

  3. #3
    Join Date
    Dec 2004
    Posts
    83
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by mastergeek70 View Post
    Sure, you can put in an include statement in the head of your page that references another page (we'll call 'checkforframes.aspx') and passes the name of the page via querystring. The page 'checkforframes.aspx' can check to see if it is the top frame using javascript "if (top == self)". If the page is the top frame, then pass the name of the page from querystring to your frames.aspx page using querystring again so that it is embedded into a frameset. If 'checkforframes.aspx' determines that your page is not the top frame, then it returns silently back to your application.
    thanls for the info...is there any websites or articles where I can learn more about it? Mayve sample files/codes?

    viktor

  4. #4
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    This example uses ASP.NET, you will need the MS .NET framework.

    Locally viewing http://localhost/frames.aspx will show the framed content1.aspx. If you view http://localhost/content1.aspx it will automatically frame itself. You can substitute content1.aspx for any page as long as it has the include statement.

    CheckIfInFrames.inc
    Code:
    <%  Dim strDefpath,strFinal as string
      strDefpath = Request.ServerVariables("PATH_INFO")
      If Left$(strDefpath, 1) = "/" Then strDefpath = Right$(strDefpath, Len(strDefpath) - 1)
      strFinal = "http://localhost/frames.aspx?target=" & strDefpath
    %>
    
    <html>
    <head></head>
    <body onload="redirect('<%=strFinal%>');"></body>
    
    <script type="text/javascript">
    
    function redirect(strFinal){
       if (top == self){
          window.location=strFinal;
       }
    }
    
    </script> 
    </html>
    frames.aspx

    Code:
    <%@ Page Language="VB"%>
    <script runat="server">
    
    'Globals
    Dim strTarget as String
    ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    Sub Page_Load
    
      strTarget = Request.QueryString("target")
      if strTarget="" then strTarget="content1.aspx"
    
    End Sub
    ' =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    
    </script>
    <html>
    
    <head>
    <title>Frames Page</title>
    </head>
    
    <frameset cols="250,*">
      <frame name="contents" target="main" src="Menu.aspx">
      <frame name="main" src="<%=strTarget%>">
      <noframes>
      <body>
    
      <p>This page uses frames, but your browser doesn't support them.</p>
    
      </body>
      </noframes>
    </frameset>
    </html>
    Menu.aspx

    Code:
    <%@ Page Language="VB"%>
    
    <script runat="server">
      Sub Page_Load
      End Sub
    </script>
    <html>
         <head><title>Menu Page</title>
              
              <style type="text/css">
                   BODY   {font-family:arial;font-size: 9pt;}
              </style>
              
         </head>
    <body>          
        Menu Page
    </body>
    </html>
    content1.aspx

    Code:
    <%@ Page Language="VB"%>
    
    <script runat="server">
       Sub Page_Load
       End Sub
    </script>
    <html>
         <head><title>Title Of Page</title>
    
         <!--#include file="CheckIfInFrames.inc"-->
              
              <style type="text/css">
                   BODY   {font-family:arial;font-size: 9pt;}
              </style>
              
         </head>
    <body>          
        Content1 Page
    </body>
    </html>
    ==============================================================================================================
    Disclaimer: The provider of this code offers no warranties or assurances of any kind. The code may or may not be 100% compliant with every single coding standard up to the current date, hour or minute. If you are a whiney, pretentious "code nazi" offended by the occasional use of deprecated tags, non-shorthand CSS, voluminous use of ASP.NET, or other preferences chosen by the provider, then bypass this post or leave the website completely - this is not for you.
    ==============================================================================================================
    Last edited by mastergeek70; 11-29-2006 at 03:56 PM.

  5. #5
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    **Shrugs** ASP.net - It's disgusting as a programming language
    Microsoft should stick to it's own part - developing software.
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  6. #6
    Join Date
    Nov 2006
    Posts
    17
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quick! Get the net, I reeled one in!

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    I'm eagerly awaiting Twey's response. Or perhaps Mike. Maybe John.
    //waits.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •