Solved

Controll frame's content on event onload

Posted on 2001-07-01
9
257 Views
Last Modified: 2008-03-03
This is my frameset :

<frameset border=0 rows="71,*,15">
<frame name=up src="up.html" frameborder=no scrolling=no noresize>
     <frameset border=0 cols="88,*" >
          <frame name=left src="left.html" frameborder=no scrolling=no noresize>
               <frameset border=1 rows="82,*" >
                 <frame name=menu src="menu.html" frameborder=no scrolling=no noresize>
                 <frame name=main src="main.html" frameborder=no scrolling=auto>
               </frameset>
</frameset>
<frame name=down src="down.html" frameborder=no scrolling=no noresize>
</frameset>



I need to change specific image in frame name- MENU
each time the MAIN frame is loading.
Meaning:

in main.html ---
<body onload=FixMenuImage('xxx.gif')>

How do tell the MENU-frame to change the image ???

0
Comment
Question by:ileens
  • 5
  • 4
9 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242230
function FixMenuImage(img) {
   if (!document.images) return
   if (top.menu && top.menu.document.images['imagename'])
top.menu.document.images['imagename'].src=img;
}
0
 

Author Comment

by:ileens
ID: 6242254
mplungjan:

Please explain your comment.

Thanks Ileen.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6242922
you have an image in the menu frame?

Syntax for chaning images is
(window.)document.images['imagename'].src='image.gif'

If it is coded like this:
<img src="yyy.gif" name="myImage">
either
top.menu.document.images['myImage'].src='xxx.gif'
or
top.left.menu.document.images['myImage'].src='xxx.gif'

In a function it would be

function FixMenuImage(img) {
top.left.menu.document.images['myImage'].src=img
}

but since menu might not have been loaded or main was loaded outside the frameset, I add a test:

function FixMenuImage(img) {
   if (!document.images) return; /* this browser does not support image swapping */
   if (top.left && top.left.menu &&
    top.left.menu.document.images['myImage']) { /*Is the frame, document and image there? */
   top.left.menu.document.images['myImage'].src=img
}



Michel
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:ileens
ID: 6243950
Thank you Michel.

It keeps giving me two Errors:

When loading the frameset,
1. Expected '}'
2. Object expected.

It doesn't get to the function it stops on the declaretion
(Definition) in the Onload event.
My syntax is :

<body LANGUAGE=javascript onload="return FixMenuImage('images/title_company.gif')">

And the same function as you wrote it.

(In the Manu page I only set the name inside the img tag.
 Do I need to set a verible or something?)

Thanks for your help.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6244253
Missed a curly:

function FixMenuImage(img) {
   if (!document.images) return; /* this browser does not support image swapping */
   if (top.left && top.left.menu &&
       top.left.menu.document.images['myImage']) { /*Is the frame, document and image there? */
      top.left.menu.document.images['myImage'].src=img
   }
}

Michel
0
 

Author Comment

by:ileens
ID: 6244271
Yes i saw it allready Sorry stupit mistake, but it still
doesn't work .

The image in Menu.html stays the same nothing is changing.

I put an alert to check if the function gets the new image
and it does - but no change in the Menu frame.

Comments??
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 6244525
Please zip and send me the frameset, menu main and images
michel@irt.org
0
 

Author Comment

by:ileens
ID: 6247759
Michel
Thank you it works great.
If you can just add the function here so I can
accept your comment as answer.

See Ya'
Ileen.
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 60 total points
ID: 6247823
function FixMenuImage(img) {
   if (!document.images) return; /* this browser does not support image swapping */
   if (parent.menu && parent.document.images['myImage']) { /*Is the frame, document and image there? */
      parent.menu.document.images['myImage'].src=img
}

Michel
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question