Change properties of <DIV> in another frame using javascript

Stevius
Stevius used Ask the Experts™
on

I am looking for the code to Change a property of <DIV>-tag in another frame. I would like to change the visibility of a DIV from another frame in a frameset.

Thanks,
Stevius
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Michel PlungjanIT Expert
Top Expert 2009

Commented:
This would work in IE5+ NS6+

top.otherframe.document.getElementById('div1').style.visibility='hidden';

Author

Commented:
Do you have an idea for earlier versions of IE & NS?
Can you also help me how to change the text of a DIV?
Thanks
IT Expert
Top Expert 2009
Commented:
txt = '<h1>Hello</h1>';
if (document.getElementById) { IE5+/NS6+
  theDiv = top.otherframe.document.getElementById('div1');
  theDiv.innerHTML=txt
  theDiv.style.visibility='visible';
}
else if (document.all) {
  theDiv = top.otherframe.document.all('div1');
  theDiv.innerHTML=txt
  theDiv.style.visibility='visible';
}
else if (document.layers) {
  theDiv = top.otherframe.document.layers['div1'];
  theDiv.document.write(txt);
  theDiv.document.close();
  theDiv.visibility='visible'; // or 'show' ??
}



Michel

Author

Commented:

Thanks,
Steve
Michel PlungjanIT Expert
Top Expert 2009

Commented:
Sorry - missed a comment

txt = '<h1>Hello</h1>';
if (document.getElementById) {// IE5+/NS6+
 theDiv = top.otherframe.document.getElementById('div1');
 theDiv.innerHTML=txt
 theDiv.style.visibility='visible';
}
else if (document.all) { // IE4+
 theDiv = top.otherframe.document.all('div1');
 theDiv.innerHTML=txt
 theDiv.style.visibility='visible';
}
else if (document.layers) { // NS4
 theDiv = top.otherframe.document.layers['div1'];
 theDiv.document.write(txt);
 theDiv.document.close();
 theDiv.visibility='visible'; // or 'show' ??
}

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial