How do you control the inline iframe scrolling in the page? method is to use the scroll method of the iframe window, you can refer to the following example
How do you control the inline iframe scrolling in the page? The method is to use the scroll method of the iframe window: 1, get the Window object of the IFRAME var iwin = document.getElementById (' iframe1 '). contentwindow; 2, get the window of the IFrame Document object var doc = iwin.document; 3, invoke the iframe window Object Scroll method Iwin.scroll (0,doc.body.scrollheight); Scroll two parameters for X,y axis rolling amount Doc.body.scrollHeight is the height of the IFRAME page (contains the part not shown) A comprehensive application example is as follows: code as follows: <html> <head> <meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "> <title>hover test</title> <style type=" text/css "> ul{ Background-color: #ff00ff; display:block; } TOC li{ position:relative; :10em; background-color: #00ff00; display:block; } Li a { /*display:block;*//* If displayed in block mode, it will fill the entire parent element space */ Background-color: #0000ff; }/* must make a block-level element */ Li a i{  display:none; } Li a:hover{ text-align:left; }/* The code added here is just for the IE6 to show, no special features, In addition to Text-decoration,color,z-index can write */ TOC li a:hover i{ display:block; width:6em; position:absolute; top:0; left:100%; /* Here 100% refers to the width relative to the element Li */ margin:-1em 0 0 0em; padding:1em; background: #cde; border:1px Solid nbsp text-align:left; z-index:10000; } </style> </head> <body> <iframe id= "iframe1" src= "width=" "height=" ></iframe> HTML code -< UL class= "TOC" id= "TOC" > <li><a href= "1.html" >chapter 1<i>in which a dragon is seen</i> </a></li> <li><a href= "2.html" >chapter 1<i>in which a knight is summoned</i> </a></li> <li><a href= "3.html" >chapter 1<i>in which a proncess is disappointed< /i></a></li> <li><a href= "4.html" >chapter 1<i>in which a dragon is seen</i></a> </li> <li><a href= "5.html" >chapter 1<i>in which a dragon is seen</i></a>< /li> <li><a href= "6.html" >chapter 1<i>in which a dragon is seen</i></a></li > <li><a href= "7.html" >chapter 1<i>in which a dragon is seen</i></a></li> </ul> <script language= "javascript" > function Getelementabspos (e) { var t = E .offsettop; var L = e.offsetleft; while (e = e.offsetparent) { T + = e.offsettop; L + = e.offsetLeft; } return {left:l,top:t}; } function getPosition (obj) { var left = 0; var top = 0; while (obj!= document.body) { left = obj.offsetleft; top = obj.offsettop; obj = ob j.offsetparent; } Returnleft; } var lis = document.getelementsbytagname (' li '); var iwin = document.getElementById (' Iframe1 ') .contentwindow; var doc = iwin.document; for (var i=0;i<lis.length;i++) { Lis[i]. onmouseover = function () { var Obji = this.childnodes[0].childnodes[1]; Doc.writeln (' <br> ' + Obji.innertext + ', ' + getelementabspos (document.getElementById (' TOC ')); Doc.writeln (' <br> ' + Obji.offsetleft + ', ' + Getelementabspos (Obji). Left + ', ' + obji.offsetwidth+ ', ' + obji.style.left '; Doc.writeln (' & Lt;br><b> ' + doc.body.scrollHeight + ' </b> ') Iwin.scroll (0,doc.body.scrollheight); / Iwin.scrollto (10000); Invalid } } </script> </body> </html>