A button in frame one that simulates clicking a button in frame two.
Call a function in another frame
Check if all frames have loaded
Creating a link to close a frameset
Find information about another frame
Print a specific frame in a frameset
Scroll 2 frames together
Sequencial loading
View source of one frame from another frame
View location of page in one frame in titlebar

A button in frame one that simulates clicking a button in frame two.

<form>
<input type="button" onclick="parent.frameName.formName.buttonName.click()">
</form>

Or:

<form>
<input type="button" onclick="parent.frames[0].formName.buttonName.click()">
</form>


Call a function in another frame

onclick=parent.FrameName.functionName();


Check if all frames have loaded


<script type="text/javascript">
<!--
count=0
function chk_loading(){
count++
if(count==parent.frames.length){
alert("All Frames Loaded")
}
}
//-->
</script>

All frame tags to include "onload=chk_loading()"


Creating a link to close a frameset

If you open a frameset in a new browser window it is possible to close that frameset, similar to closing a window, by using the following code:

<A HREF=JavaScript:window.top.close()>Close Frameset</A>


Find information about another frame

This is set up to gather information from this iframe.
domain
referrer
history
cookie
href
title
bgColor fgColor
links linkColor alinkColor vlinkColor
lastModified images forms frames

<script type="text/javascript">
<!--
function framechk() {
parent.main.document.details.domain.value = parent.main.document.domain
parent.main.document.details.ref.value = parent.main.document.referrer
parent.main.document.details.hist.value = parent.main.window.history.length
parent.main.document.details.cookie.value = parent.main.document.cookie
parent.main.document.details.href.value = parent.main.location.href
parent.main.document.details.title.value = parent.main.document.title
parent.main.document.details.bgcolor.value =parent.main.document.bgColor
parent.main.document.details.fgcolor.value = parent.main.document.fgColor
parent.main.document.details.linkcol.value = parent.main.document.linkColor
parent.main.document.details.alinkcol.value = parent.main.document.alinkColor
parent.main.document.details.vlinkcol.value = parent.main.document.vlinkColor
parent.main.document.details.links.value = parent.main.document.links.length
parent.main.document.details.images.value = parent.main.document.images.length
parent.main.document.details.forms.value = parent.main.document.forms.length
parent.main.document.details.lastmod.value = parent.main.document.lastModified
parent.main.document.details.frames.value = parent.window.frames.length
}
//-->
</script>

parent.framename.document.formname.inputname.value ="value" .....is the frame location of the form.
parent.framename.document.query .....is the frame that is checked.
parent.window .....is to enable the number of frames to be counted.

<form name="details">
<input type="button" value="Details" onClick="framechk()">
domain <input type="textbox" name="domain" value="" size="40">
referrer <input type="textbox" name="ref" value="" size="40">
history <input type="textbox" name="hist" value="" size="3">
cookie <input type="textbox" name="cookie" value="" size="40">
href <input type="textbox" name="href" value="" size="40">
title <input type="textbox" name="title" value="" size="40">
bgColor <input type="textbox" name="bgcolor" value="" size="8">
fgColor <input type="textbox" name="fgcolor" value="" size="8">
links <input type="textbox" name="links" value="" size="3">
linkColor <input type="textbox" name="linkcol" value="" size="8">
alinkColor <input type="textbox" name="alinkcol" value="" size="8">
vlinkColor <input type="textbox" name="vlinkcol" value="" size="8">
images <input type="textbox" name="images" value="" size="3">
forms <input type="textbox" name="forms" value="" size="3">
lastModified <input type="textbox" name="lastmod" value="" size="20">
frames <input type="textbox" name="frames" value="" size="3">
</form>


Print a specific frame in a frameset

<script type="text/javascript">
<!--
function printFrame(){
if(window.print){
parent.framename.focus();
parent.framename.print()}
}
// -->
</script>

< href="#null" onclick="printFrame()">Print</a>

Where framename is the name of the frame


Scroll 2 frames together

The following script would go in the page in frame 2 so that when frame 2 is scrolled frame 1 scrolls in sync.

<script type="text/javascript">
<!--
moz=document.getElementById&&!document.all
function scrollme(){
if(!moz){
parent.frame1.document.body.scrollTop=parent.frame2.document.body.scrollTop
}
else{
parent.frame1.scrollTo(0,parent.frame2.pageYOffset)
}
}
onscroll=scrollme
// -->
</script>


Sequencial loading

Systematically load frames

Any frame that is going to be loaded in sequence should be initially loaded with a blank page otherwise you will get the "Page not found" page.
The sequencial loading is started once the frameset has loaded.
In each of the frame tags the onload event is added to call a function which counts the number of frames, the first counts equal to the number of frames in the frameset are ignored for the initial loading of the frameset then another function is run which loads the pages into the appropiate frame.

Open Example frameset

<script type="text/javascript">
<!--
count=0
chk=0
function chk_loading(){
count++

if(chk==0){
if(count<parent.frames.length){return} // do not proceed until initial loading of frames is complete

if(count==parent.frames.length){ // reset counter once initial loading of frames is complete
count=1
chk=1
}
}

setTimeout("load_frame()",1000) // load a frame

}

function load_frame(){
if(count==1){parent.frames["f1"].location="header.htm"}
if(count==2){parent.frames["f2"].location="menu.htm"}
if(count==3){parent.frames["f3"].location="page1.htm"}
}

//-->
</script>

An example frameset

<frameset rows="20%,75%">
<frame id="f1" src="blank.htm" NAME="header" scrolling="no" onload="chk_loading()">

<frameset cols="25%,75%">
<frame id="f2" src="blank.htm" NAME="menu"scrolling="no" noresize onload="chk_loading()">
<frame id="f3" src="blank.htm" NAME="contents" scrolling="auto" noresize onload="chk_loading()">
</frameset>

</frameset>


View source of one frame from another frame

window.location =' view-source:' + parent.framename.location


View location of page in one frame in titlebar

parent.document.title=parent.framename.document.location.href


document.frames['main'].getElementsByTagName('body')[0].focus()