![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
When a search engine finds a page that page might properly belong in a frame. Previous code enabled us to load the frame which should contain the orphan frame, but the frame would load with its default pages and the surfer would have to find the page again.
You can load stray pages into their frames by using this code. First put the function in the frameset page below in your frameset page, changing the name of the frame where you want to load the page to one suiting your own page (change "lowerPage"). Call the function in the framset's onload event:
<
html><
head><
title>Orphan Frame Example</title><!-- This is the frames page -->
<!-- Copy the code below to your frames page -->
<script type=
"text/javascript">function
setPage() {if
(location.search){
var mypage = location.search.substring(1,location.search.length);//change only the name, "lowerPage", below to the name of the frame
//where you want to load the orphan page
lowerPage.location=mypage;
}
}
//end of setPage()</script>
<!-- end of copying, but do not forget the onload below-->
<
/head><
frameset cols="25%,*" onload="setPage()"><!-- add the "onload" code to your frameset, and that's all-->
<
frame name="side" src="orphanSide.htm" target="lowerPage"><
frameset rows="50%,*"><
frame name="upperPage" src="orphanTop.htm"><
frame name="lowerPage" src="orphanBottom.htm"><
/frameset><
/frameset><
/html>
Next put the following code in the next page into your own frame pages:
<html>
<head>
<title>MY FILE</title>
<!-- Add the script below to the HEAD of your page -->
<script type="text/javascript">
function
loadInFrame() {//change the page, "orphanFrame.html" to the name of your
//frameset page
var
framePage = 'orphanFrame.html'if
(top.location == self.location){
if (confirm('This page is normally in a frame. Do you wish to load it in its frame?')) //you can delete the line above, if you wish to load anyway {window.location = framePage +
'?'+ window.location.pathname }}
}
//end of loadInFrame()</script>
<!-- end of copying script. Don't forget to add the "onload"
in the body tag-->
<
/head><!-- Add the onload code below to your page, and that's it!-->
<
body bgcolor="white" onload="loadInFrame()"><
h1>Orphan Page</h1><
/body><
/html>
By clicking on this link, you can see the code in action.