Solved

Controll frame's content on event onload

Posted on 2001-07-01
9
249 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
 

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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
es6 typescript how to filter an array 10 39
HTML page and JavaScript 2 54
angularls and plnkr 14 19
jqplot Pie Chart - javascript 2 17
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now