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.
==============================================================================================================
Bookmarks