Solved

Controll frame's content on event onload

Posted on 2001-07-01
9
259 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…

730 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