470,849 Members | 1,590 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,849 developers. It's quick & easy.

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.document;
alert(bannerFrame.name);
alert(bannerDoc.URL);
}
// -->
</script>
</head>
<frameset frameborder="0" rows="10%,*" onLoad="load();">
<frame id="banner" name="banner"
src="banner.htm" noresize="noresize" scrolling="no"
onLoad="bannerFrame=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
Jul 23 '05 #1
1 1085
Ken Kast wrote:
I have a frameset page with the following code snippets:

.
.
.
<script type="text/javascript">
<!--
var bannerFrame;
function load () {
var bannerDoc = bannerFrame.document;
alert(bannerFrame.name);
alert(bannerDoc.URL);
}
// -->
</script>
</head>
<frameset frameborder="0" rows="10%,*" onLoad="load();">
<frame id="banner" name="banner"
src="banner.htm" noresize="noresize" scrolling="no"
onLoad="bannerFrame=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


<script type="text/javascript">
function load () {
alert(window.frames['banner'].location.href);
}
</script>
</head>
<frameset frameborder="0" rows="10%,*" onload="load();">
<frame id="banner" name="banner"
src="about:blank" noresize="noresize" 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=this), then it fails
in both Opera and Netscape 4 with "bannerFrame undefined".

--
| Grant Wagner <gw*****@agricoreunited.com>

* Client-side Javascript and Netscape 4 DOM Reference available at:
*
http://devedge.netscape.com/library/...ce/frames.html

* Internet Explorer DOM Reference available at:
*
http://msdn.microsoft.com/workshop/a...ence_entry.asp

* 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
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Scott W Gifford | last post: by
2 posts views Thread by doug s | last post: by
6 posts views Thread by Jay Bienvenu | last post: by
2 posts views Thread by TT (Tom Tempelaere) | last post: by
reply views Thread by Ben Holness | last post: by
4 posts views Thread by spivee | last post: by
12 posts views Thread by e271828 | last post: by
275 posts views Thread by Astley Le Jasper | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.