[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

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

0
ileens
Asked:
ileens
  • 5
  • 4
1 Solution
 
Michel PlungjanIT ExpertCommented:
function FixMenuImage(img) {
   if (!document.images) return
   if (top.menu && top.menu.document.images['imagename'])
top.menu.document.images['imagename'].src=img;
}
0
 
ileensAuthor Commented:
mplungjan:

Please explain your comment.

Thanks Ileen.
0
 
Michel PlungjanIT ExpertCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
ileensAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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
 
ileensAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
Please zip and send me the frameset, menu main and images
michel@irt.org
0
 
ileensAuthor Commented:
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
 
Michel PlungjanIT ExpertCommented:
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now