Determine directory level of file calling function
<p>If there is a function in an iframe,  that loads a file, that file tries to load from the "base href" of the iframe that calls the function. </p>

<pre><code>function load_it(){
    top.iframe_1.location='sub_1/file_1.php'
}
</code></pre>

<p>The above will work only if called from the top page.
If called from <code>/sub_1/</code> it tries to load <code>/sub_1/sub_1/file_1.php</code>
If called from <code>/sub_1/sub_2/</code> it tries to load <code>/sub_1/sub_2/sub_1/file_1.php</code></p>

<p>So I need to prefix '', '../' or '../../' depending on the depth of the calling page.</p>

<p>ie: <code>../../sub_1/file_1.php</code></p>

<p>How can I determine the sub directory level that is needed, within the <code>load_it</code> function?</p>
