Finding the right document

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ken Kast

    Finding the right document

    I have a frameset page with the following code snippets:

    ..
    ..
    ..
    <script type="text/javascript">
    <!--
    var bannerFrame;
    function load () {
    var bannerDoc = bannerFrame.doc ument;
    alert(bannerFra me.name);
    alert(bannerDoc .URL);
    }
    // -->
    </script>
    </head>
    <frameset frameborder="0" rows="10%,*" onLoad="load(); ">
    <frame id="banner" name="banner"
    src="banner.htm " noresize="nores ize" scrolling="no"
    onLoad="bannerF rame=this;" />
    ..
    ..
    ..
    When I run this the first alert message gives me the correct name. The
    second alert gives me the url of the frameset page, not of the frame page.
    Why is this, and how should I modify the script so that I can grab the
    document for the frame?

    Thanks.

    Ken


  • Grant Wagner

    #2
    Re: Finding the right document

    Ken Kast wrote:
    [color=blue]
    > I have a frameset page with the following code snippets:
    >
    > .
    > .
    > .
    > <script type="text/javascript">
    > <!--
    > var bannerFrame;
    > function load () {
    > var bannerDoc = bannerFrame.doc ument;
    > alert(bannerFra me.name);
    > alert(bannerDoc .URL);
    > }
    > // -->
    > </script>
    > </head>
    > <frameset frameborder="0" rows="10%,*" onLoad="load(); ">
    > <frame id="banner" name="banner"
    > src="banner.htm " noresize="nores ize" scrolling="no"
    > onLoad="bannerF rame=this;" />
    > .
    > .
    > .
    > When I run this the first alert message gives me the correct name. The
    > second alert gives me the url of the frameset page, not of the frame page.
    > Why is this, and how should I modify the script so that I can grab the
    > document for the frame?
    >
    > Thanks.
    >
    > Ken[/color]

    <script type="text/javascript">
    function load () {
    alert(window.fr ames['banner'].location.href) ;
    }
    </script>
    </head>
    <frameset frameborder="0" rows="10%,*" onload="load(); ">
    <frame id="banner" name="banner"
    src="about:blan k" noresize="nores ize" scrolling="no" />
    </frameset>

    Works in IE6SP1, Firefox 0.8, Opera 7.23. In Netscape 4 you get "access
    disallowed from scripts at <uri> another domain." but that's probably only
    because I'm using about:blank.

    If you try it using your code (ie - setting bannerFrame=thi s), then it fails
    in both Opera and Netscape 4 with "bannerFram e undefined".

    --
    | Grant Wagner <gwagner@agrico reunited.com>

    * Client-side Javascript and Netscape 4 DOM Reference available at:
    *


    * Internet Explorer DOM Reference available at:
    *
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.


    * Netscape 6/7 DOM Reference available at:
    * http://www.mozilla.org/docs/dom/domref/
    * Tips for upgrading JavaScript for Netscape 7 / Mozilla
    * http://www.mozilla.org/docs/web-deve...upgrade_2.html


    Comment

    Working...