Link to home
Start Free TrialLog in
Avatar of ileens
ileens

asked on

Controll frame's content on event onload

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 ???

Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

function FixMenuImage(img) {
   if (!document.images) return
   if (top.menu && top.menu.document.images['imagename'])
top.menu.document.images['imagename'].src=img;
}
Avatar of ileens
ileens

ASKER

mplungjan:

Please explain your comment.

Thanks Ileen.
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
Avatar of ileens

ASKER

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.
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
Avatar of ileens

ASKER

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??
Please zip and send me the frameset, menu main and images
michel@irt.org
Avatar of ileens

ASKER

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.
ASKER CERTIFIED SOLUTION
Avatar of Michel Plungjan
Michel Plungjan
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial