Forum Moderators: open
I am reading up on how to do this in my trusty o'reilly's book and it seems to say that both IE and NN treat frames similar to window objects. Therefore you can change their url or src by targeting it using its name.
maybe something like this?
onLoad="changeSideFrameUrl();"
function changeSideFrameUrl () {
sideframe.location = "somepage.html";
}
it says urls can be full or relative and it would seem that this should work but I am far from a js expert.
The first thing to understand is how frames are referenced. Suppose you have this frameset:
<frameset cols="200,*">
<frame name="left" src="nav.html" />
<frame name="main" src="index2.html" />
</frameset>
The main top-level browser window (which has no name) now has two "children", called "left" and "main". These children are stored as properties of the top-level window itself.
You have a script in main which wants to change properties in left. You can't access left directly, you have to access it as a property of the parent window:
window.parent.left
The location object of left can be accessed like this:
window.parent.left.location
What you want to do (if possible) is to load a different document into "left" without creating a new entry in that window's History list. There is a method that will do that: it's Location.replace(), and you use it like this:
window.parent.left.location.replace('newpage.html');
I can't guarantee this will work exactly as you want it to (it's worth a try, though). Another possibility is this: if it's only a graphic that you want to change, and if you make all of the "This Is The Page You're On" graphics the same width and height, you can simply change the graphic in the same way you do for JavaScript rollovers. If you have this <img> tag in the left frame:
<img src="home.gif" name="heading" />
...you can change it from the main frame like this:
window.parent.left.heading.src="newpage.gif";
However, I would strongly recommend talking your client out of using frames at all. Here are the reasons:
1. Search engines have trouble with them.
2. They are passé.
3. Future browsers might not support them.
4. They increase the load on the server, making it slower, less efficient and also raising costs.
(OK, that's a little contrived. The problems involved with using frames are more subtle than that, but you have to hit clients where it hurts: tell them it's expensive and won't get them indexed on search engines and they'll come around to your way of thinking sooner or later.)
<frameset cols="200,*">
<frame id="left" name="left" src="nav.html" />
<frame id="main" name="main" src="index2.html" />
</frameset>
<html>
<head>
<script type = "javascript">
<!--
function changeImage()
{
window.parent.left.nowhome.src="home_now.jpg";
//-->
</script>
<title>Our Services</title>
<base target="rbottom">
</head>
<body topmargin="0" bgcolor="#FFFFFF" onLoad="changeImage()">
<added>some errors
<html>
<head>
<title>Our Services</title>
<base target="rbottom">
<script lang="javascript">
<!--
function changeImage()
{
window.parent.left.nowhome.src="home_now.jpg";
}
//-->
</script>
</head>
<body topmargin="0" bgcolor="#FFFFFF" onLoad="changeImage();">
you didn't close the brace at the end of the function