faqts : Computers : Programming : Languages : JavaScript : Frames

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

23 of 49 people (47%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

How can I change the SCROLLING attribute of a FRAME?

Apr 20th, 2000 12:41
Martin Honnen,


Only IE4+ can do that (though NN6 should allow it too but seems buggy 
at the time of writing). ID your FRAME e.g.
  <FRAME ID="frame0" ...>
then script
  top.document.all['frame0'].scrolling = 'yes'/'no'/'auto'
respectively
  top.document.getElementById('frame0').scrolling = 'yes'/'no'/'auto'

Here is a complete example:

<HTML>
<HEAD>
<SCRIPT>
var scrolling = false;
function initFrames () {
  var html = '';
  html += '<HTML><BODY>';
  html += '<A HREF="javascript: top.toggleScrolling(); void 0">';
  html += 'toggle scrolling';
  html += '<\/A>';
  html += '<\/BODY><\/HTML>';
  frame0.document.open();
  frame0.document.write(html);
  frame0.document.close();
  html = '';
  html += '<HTML><BODY>';
  for (var i = 0; i < 40; i++)
    html += 'JavaScript.FAQTs.com<BR>';
  html += '<\/BODY><\/HTML>'
  frame1.document.open();
  frame1.document.write(html);
  frame1.document.close();
}
function toggleScrolling () {
  scrolling = !scrolling;
  var frameElement =
    document.all ? document.all['frame1'] :
    document.getElementById ? document.getElementById('frame1') :
    null;
  if (frameElement)
    frameElement.scrolling = scrolling ? 'yes' : 'no';
}
</SCRIPT>
</HEAD>
<FRAMESET ROWS="50%, 50%"
          ONLOAD="initFrames()"
>
<FRAME NAME="frame0" SRC="about:blank">
<FRAME ID="frame1" NAME="frame1" SRC="about:blank" SCROLLING="no">
</FRAMESET>
</HTML>