Why is 'self' what it is?
<p>I have a frame page....</p>

<pre><code>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
"http://www.w3.org/TR/html4/frameset.dtd"&gt;

&lt;html&gt;
  &lt;head&gt;
     &lt;meta http-equiv="Content-type" content="text/html;charset=UTF-8"&gt;
     &lt;title&gt;Main title&lt;/title&gt;
    &lt;script type="text/javascript" src="JS.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;frameset rows="10%,90%" id="frameid" name="frameName"&gt;
     &lt;frame src="FrameA.htm"     name="F_A"&gt;
     &lt;frame src="FrameB.htm"     name="F_B"&gt;
  &lt;/frameset&gt;
&lt;/html&gt;
</code></pre>

<p>Here's FrameA.htm; FrameB looks similar</p>

<pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
   &lt;head&gt;
     &lt;meta http-equiv="Content-type" content="text/html;charset=UTF-8"/&gt;
     &lt;script type="text/javascript" src="JS.js"&gt;&lt;/script&gt;
     &lt;title&gt;Frame A Title&lt;/title&gt;
   &lt;/head&gt;

   &lt;body onload="parent.ldfunc()" class="Resize" id="idA"&gt;
      Body of frame A 
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and finally a javascript JS.js</p>

<pre><code>function ldfunc () {
  alert("window.self.name: " + window.self.name);
  alert("window.self.document.body.id: " + window.self.document.body.id);
}
</code></pre>

<p>Now here's the rub...</p>

<p>1) If the onload clause in the body tag is parent.ldfunc() as it is above, 'self' seems to be the frame page, not page A or page B.  I.e. Id is displayed as frameid.</p>

<p>2) If the onload clause is ldfunc() WITHOUT the parent, 'self' points at page A or page B as expected.  I.e. id is displayed as idA or iadB.</p>

<p>In other words, self seems to follow the function location, not the page.</p>

<p>Why did I try this?  I'm going to have several thousand pages that will be loaded in B by A and I thought I could eliminate the need to put the script in each of their headers.</p>

<p>Is there some way to make the script loaded by the frame page global and available to the other pages?</p>
