Jump to content

change variable from other frame's script


MK27

Recommended Posts

I've doing a site with a menu in a side frame where the menu is all images that are changed with onmouseover and onmouseout.  Because I want the active menu item highlighted, I have three images for each button (a base one, a mouse over one, and one for when the item is active).  The current active button is tracked in a variable, so that when a new button is clicked, the old one can be returned to the non-active base image.

But the user can also change the active page using in-text links, by-passing the menu.  Before I give up on the possibility, I was hoping against hope that I could call a function and/or change the value of a variable from the script on the menu page from a page in the other frame, using something like:

parent.sidebar.var1=0;

I haven't tried yet because I'm pretty sure you can't, so since this is a common set up I thought I'd also check and see if anyone knows a better option.

If I do have to re-write the sidebar functions, is there a way to check and see what specific image file is loaded into a particular place (so I could find the active item, rather than reloading all the images?)  Something like:

if (parent.sidebar.images[item].src="active.jpg") {parent.sidebar.images[item].src="base.jpg"};

Link to comment
Share on other sites

var imgray = new Array();
imgray[0] = new Array() 
imgray[0][0] = new Image();
imgray[0][0].src = "images/desc-bttn.jpg"
imgray[0][1] = new Image()
imgray[0][1].src = "images/desc-bttn2.jpg"
imgray[0][2] = new Image()
imgray[0][2].src = "images/desc-bttn3.jpg"
imgray[1] = new Array() 
[....]
var labray=new Array();
labray[0]=1;
var i;
for (i=1; i<8; i++) { labray[i]=0; }
function swaplabel (label,num) {     // for mouseout
if (labray[num]==0) {
	document.images[label].src=imgray[num][0].src;
} else {
	document.images[label].src=imgray[num][2].src;
}
}
var active=0;
function makeactive (num) {    // for onclick
labray[active]=0;
var label;
if (active==0) {label='desc_bttn';}
if (active==1) {label='uses_bttn';}
if (active==2) {label='doc_bttn';}
if (active==3) {label='config_bttn';}
        [....]
document.images[label].src=imgray[active][0].src;
active=num;
labray[num]=1;
}	

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.