Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keeping in Frames 1

Status
Not open for further replies.

TonyCronin

Programmer
Jul 16, 2001
47
0
0
GB
Hello,

I am using a frameset on my site with topFrame, leftFrame used for menus and mainFrame used for displaying an asp page that reads dynamic data. The asp page start off as main.asp and can go to other pages depending on what the user selects - story.asp, linksasp etc. I need people to be able to send a link to one of the asp pages that goes into mainFrame frame and for the page to stay in the frameset.

I have tried using a 'keep in frames' script..

<script>
if (parent.frames.length==0)
//CHANGE "index.htm" to the URL of your main frame page
window.location.replace("index.htm")
</script>

but this loads the default mainFrame page - main.asp (i.e. goes back to the homepage) rather than keeping the asp page that was linked.

Any ideas?
Thanks for your help,
TonyC
 
I also had this problem. Here is how I solved it.

Each ASP page in my site looks roughly as follows...
Code:
<%
strThisPage = "page1.asp"
%>
<!-- #include file="include/header.asp" -->

PAGE CONTENT HERE

<!-- #include file="include/footer.asp" -->
The header.asp page starts off like this...
Code:
<%
If Request.QueryString <> "" Then
  strThisPage = strThisPage & "?" & Request.QueryString
End If
%>
<HTML>
<HEAD>

<SCRIPT LANGUAGE="JAVASCRIPT">
if (window == top)
	window.location = "<%=strSitePath%>index.asp?url=<%=Server.URLEncode(strSitepath & strThisPage)%>";
</SCRIPT>
and finally, the frameset page (index.asp) looks a bit like this...
Code:
<%
If Request.QueryString("url") <> "" Then
  strMainPage = Request.QueryString("url")
Else
  strMainPage = "home.asp"
End If
%>

<FRAMESET ROWS="37,*" FRAMESPACING=0 FRAMEBORDER=0 BORDER=0>
    <FRAME NAME=topnav SRC="include/top.asp" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=no FRAMEBORDER=0 BORDER=0 NORESIZE>
    <FRAME NAME=main SRC="<%=strMainPage%>" MARGINWIDTH=0 MARGINHEIGHT=0 SCROLLING=auto FRAMEBORDER=0 BORDER=0 NORESIZE>
</FRAMESET>

If there's anything you can't follow then give me a shout.

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
thinking about it, instead of having...
Code:
strThisPage = "page1.asp"
...at the top of each page, you could probably use...
Code:
strThisPage = Request.ServerVariables("SCRIPT_NAME")
...at the top of header.asp.

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
This is great and I almost have it I think.. the page is loading frameset and loading a page based on strMainPage into mainFrame.. problem is its an invalid page caused by frameset page.. code for frameset is..

<frame name="mainFrame" marginwidth="0" marginheight="0" scrolling="AUTO" frameborder="NO" SRC=<%=strMainPage%>">

and the missing page is..


I have tried with "" too.. im not sure what the correct syntax is to include this variable in the frame tag..

Many Thanks,
Tony
 
is your frameset page an ASP page?

you also have a missing quote
Code:
<frame name="mainFrame" marginwidth="0" marginheight="0" scrolling="AUTO" frameborder="NO" SRC=[COLOR=red][b]"[/b][/color]<%=strMainPage%>">

Tony
reddot.gif WIDTH=500 HEIGHT=2 VSPACE=3

 
Errmmm no.. it was index.htm - i should have spotted that..

Changed to index.asp and this works just as i wanted it to now. Thanks Tony this has been a big help..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top