faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

178 of 218 people (82%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

How can I script one frame from another?
How can I script one window from another?

Mar 1st, 2000 22:18
Martin Honnen,


The usual objects you script inside a window e.g.
  document
  history
  location
  varName
  methodName()
are just properties of the window object and the above are just 
shortcuts for
  window.document
  window.history
  window.location
  window.varName
  window.methodName()
If you replace window with a reference to another window object you can 
script that as well (subject to cross domain security restrictions). To 
access a frameset window from inside a frame you acess the
  parent
object so
  parent.document
  parent.location
etc scripts the containing window for a frame.
  parent.frameName
is the reference to the <FRAME NAME="frameName" ...> sibling thus
  parent.frameName.document
  parent.frameName.location
  parent.frameName.varName
  parent.frameName.functionName()
scripts another frame.
For windows in a opening/opener relationship you just use another 
window handle: if you open a window with js keep a reference with
  var windowRef = open ('whatever.html', 'windowName');
then you can script
  windowRef.document
  windowRef.location
  windowRef.close()
etc.
The opened window refers back to the other window with
  window.opener
thus
  window.opener.document
  window.opener.location
  window.opener.varName
  window.opener.close()
scripts the opening window.