Log in

View Full Version : frames



viktor
11-22-2006, 06:38 PM
is there way to keep a page inside a frame if it has a code that breaks the frame?

mastergeek70
11-23-2006, 01:59 PM
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.

viktor
11-23-2006, 05:45 PM
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

mastergeek70
11-28-2006, 04:13 AM
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

<% 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


<%@ 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


<%@ 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



<%@ 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.

==============================================================================================================

tech_support
11-28-2006, 06:38 AM
**Shrugs** ASP.net - It's disgusting as a programming language
Microsoft should stick to it's own part - developing software.

mastergeek70
11-28-2006, 02:02 PM
Quick! Get the net, I reeled one in!

djr33
11-28-2006, 02:15 PM
I'm eagerly awaiting Twey's response. Or perhaps Mike. Maybe John.
//waits.