laoding
          本來我以為,隱身了別人就找不到我,沒有用的,像我這樣拉風的男人,無論走到哪里,都像在黑暗中的螢火蟲一樣,那樣的鮮明,那樣的出眾。我那憂郁的眼神,稀疏的胡茬,那微微隆起的將軍肚和親切的笑容......都深深吸引了眾人......
          posts - 0,  comments - 37,  trackbacks - 0

          本文轉載自 http://liuzi.roboticfan.com


          1.iframe也應該是框架的一種形式,它與<frame>不同的是,iframe可以嵌在網頁中的任意部分。
          <iframe src="/URL" width="x" height="x" scrolling="[OPTION]" frameborder="x"></iframe>
            src:文件的路徑,既可是HTML文件,也可以是文本、ASP等;
            width、height:"畫中畫"區域的寬與高,可以是pixel值,也可以是百分比,比如width="100%";
            scrolling 是否顯示頁面滾動條(可選的參數為 auto、yes、no,如果省略這個參數,則默認為auto);
            FrameBorder:區域邊框的寬度,為了讓“畫中畫“與鄰近的內容相融合,常設置為0(邊框寬度為0)。
              marginwidth, marginheight:控制插入頁被框架覆蓋的深度。
              vspace:控制框架覆蓋上部分的深度
            比如:
            <iframe src="http://www.xyz.com/xyz"; width="250" height="200" marginwidth=0 marginheight=0 vspace=-170 scrolling="no" frameborder="0"></iframe>

          src可以是相對URL,如src="/bgm/bgm.html"
          ....................................................................................
          2.如何使iframe背景透明
          在transparentBody.htm文件的<body>標簽中,我已經加入了style="background-color=transparent" 屬性,通過以下四種iframe的寫法我想大概你對iframe背景透明效果的實現方法應該會有個清晰的了解:
          <iframe id="Frame1" src="http://www.webjx.com/htmldata/2006-01-03/transparentBody.htm" allowTransparency="true"></iframe>
          <iframe id="Frame2" src="http://www.webjx.com/htmldata/2006-01-03/transparentBody.htm" allowTransparency="true" style="background-color: green"> </iframe>
          <iframe id="Frame4" src="http://www.webjx.com/htmldata/2006-01-03/transparentBody.htm" style="background-color: green"> </iframe>
          .....................................................................................
          3.如何實現iframe自適應窗體大小
          <script>
          function autoResize()
          {
          try
          {
          document.all["content"].style.height=content.document.body.scrollHeight
          }
          catch(e){}
          }
          </script>

          <iframe src="main.htm" name="content" id="content" scrolling="no" frameborder="0" width="100%" onload="autoResiz();"> </iframe>
          .........................
          4.iframe 父窗口和子窗口的調用方法
            在腳本語言與對象層次中,包含Iframe的窗口我們稱之為父窗體,而浮動幀則稱為子窗體,弄清這兩者的關系很重要,因為要在父窗體中訪問子窗體或相反都必須清楚對象層次,才能通過程序來訪問并控制窗體。
          父窗口調用子窗口的例子:
          exmaple.htm
          <html>
          <body onload="test.myH1.innerText='hello,my dear';">
          <Iframe src="test.htm" id="test" width="250" height="200" scrolling="no" frameborder="0"></iframe>
          </body>
          </html>
          test.htm
          <html>
          <body>
          <h1 id="myH1">hello,my boy</h1>
          </body>
          </html>
          子窗口調用父窗口的例子:
          example.htm:
          <html>
          <body>
          <Iframe name="tt" src="frame1.htm" width="250" height="200" scrolling="no" frameborder="0"></iframe>
          <h1 id="myH2">hello,my wife</h1>
          </body>
          </html>
          frame1.htm
          <body onload="parent.myH2.innerText='hello,my new wife';"></body>

          要注意的是,Nestscape6.0之前版本不支持Iframe標記。

          :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          5.用圖片代替Iframe的滾動條
          <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
          <html>
          <head>
          <title>new document</title>

          <script language="javascript">
          function scroll(n)
          {temp=n;
          Out1.scrollTop=Out1.scrollTop+temp;
          if (temp==0) return;
          setTimeout("scroll(temp)",80);
          }
          </script>
          </head>

          <body>

          <table width="330">
           <tr>
            <td width="304" valign="top" rowspan="2">
            <div id=Out1 style="width:100%; height:100;overflow: hidden ;border-style:dashed;border-width: 1px,1px,1px,1px;">
            1<br>
            2<br>
            3<br>
            4<br>
            5<br>
            6<br>
            7<br>
            8<br>
            9<br>
            10<br>
            11<br>
            12<br>
            13<br>
            14<br>
            15<br>
            16<br>
            17<br>
            18<br>
            19<br>
            20<br>
            </div>
            </td>
            <td width="14" valign="top"><img src="/blog/scrollbar.gif" width="14" height="20" onmouseover="scroll(-1)" onmouseout="scroll(0)" onmousedown="scroll(-2)" border="0" alt="按下鼠標速度會更快!"></td>
           </tr>
           <tr>
            <td width="14" valign="bottom"><img src="/blog/scrollbar.gif" onmouseover="scroll(1)" onmouseout="scroll(0)"
            onmousedown="scroll(2)" border="0" width="15" height="21" alt="按下鼠標速度會更快!"></td>
           </tr>
          </table>
          </body>
          </html>

           

          :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
          6.下面這段代碼可以實現IFrame自適應高度,即隨著頁面的長度,自動適應以免除頁面和IFrame同時出現滾動條(比上面的一個復雜)。
          源代碼如下:

          <script type="text/javascript">
          //** iframe自動適應頁面 **//

          //輸入你希望根據頁面高度自動調整高度的iframe的名稱的列表
          //用逗號把每個iframe的ID分隔. 例如: ["myframe1", "myframe2"],可以只有一個窗體,則不用逗號。

          //定義iframe的ID
          var iframeids=["test"]

          //如果用戶的瀏覽器不支持iframe是否將iframe隱藏 yes 表示隱藏,no表示不隱藏
          var iframehide="yes"

          function dyniframesize()
          {
          var dyniframe=new Array()
          for (i=0; i<iframeids.length; i++)
          {
          if (document.getElementById)
          {
          //自動調整iframe高度
          dyniframe[dyniframe.length] = document.getElementById(iframeids);
          if (dyniframe && !window.opera)
          {
          dyniframe.style.display="block"
          if (dyniframe.contentDocument && dyniframe.contentDocument.body.offsetHeight) //如果用戶的瀏覽器是NetScape
          dyniframe.height = dyniframe.contentDocument.body.offsetHeight;
          else if (dyniframe.Document && dyniframe.Document.body.scrollHeight) //如果用戶的瀏覽器是IE
          dyniframe.height = dyniframe.Document.body.scrollHeight;
          }
          }
          //根據設定的參數來處理不支持iframe的瀏覽器的顯示問題
          if ((document.all || document.getElementById) && iframehide=="no")
          {
          var tempobj=document.all? document.all[iframeids] : document.getElementById(iframeids)
          tempobj.style.display="block"
          }
          }
          }

          if (window.addEventListener)
          window.addEventListener("load", dyniframesize, false)
          else if (window.attachEvent)
          window.attachEvent("onload", dyniframesize)
          else
          window.onload=dyniframesize
          </script>
          ::::::::::::::::::::::::::::::::::::::::::::::
          7.iframe應用之動態獲取并替換網頁內容
            
             經常上論壇都能看的到,如果點擊某個主題會出現“正在讀取改貼的跟貼,請稍后.....”等的字眼。之后就顯示了該主題的跟貼的一些相關信息。由于這幾天要做類似于這種方式的BBS,所以就拿了一個BBS網站來研究一把,經過半天的查看源碼和實踐終于弄懂了。

             它主要的是Iframe和innerHTML結合的結晶。下面是一個簡單的示范:

          page1.htm


          <html>

          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>page1</title>
          </head>

          <body>
          <script language="javascript">

          function loadContent(){
            //顯示隱藏的提示內容
           document.all.tr2.style.display="block"; 
            //重新刷新iframe1的內容
           document.frames["iframe1"].location.replace("page2.htm");
          }

          </script>

          <!--精華所在,用隱藏的iframe來作為外部數據的來源-->

          <iframe   id="iframe1" width="0" height="0" name="I1"></iframe>

          <table>
            <tr id="tr1" ><!--DISPLAY: none是把這行隱藏-->
            <td style="cursor:hand" onclick="loadContent()">
                點擊這里你會有新發現。。。
            </td>
            </tr>
            <tr id="tr2" style="DISPLAY: none" ><!--DISPLAY: none是把這行隱藏-->
            <td>
                <div id="div_hidden">正在讀取關于本主題的跟貼,請稍侯……</div>
            </td>
            </tr>
          </table>

          </body>

          </html>

           

          page2.htm


          <html>

          <head>
          <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
          <title>page2</title>
          </head>

          <body>
          <script language="javascript">
             alert("準備替換提示內容!");
             parent.div_hidden.innerHTML = "你已經看到從另外一個頁面來的替換信息";
          </script>
          </body>
          </html>

          posted on 2008-11-05 22:17 老丁 閱讀(859) 評論(0)  編輯  收藏 所屬分類: html tag

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           
          本博客主為學習和復習之用,無關其他,想罵人的繞道
          Email:dkm123456@126.com
          大家一起交流進步
          QQ:283582761


          <2025年5月>
          27282930123
          45678910
          11121314151617
          18192021222324
          25262728293031
          1234567

          留言簿(4)

          我參與的團隊

          文章分類(50)

          文章檔案(48)

          相冊

          朋友

          搜索

          •  

          積分與排名

          • 積分 - 96531
          • 排名 - 600

          最新評論

          主站蜘蛛池模板: 车险| 凉城县| 徐州市| 万盛区| 郁南县| 石景山区| 无为县| 永德县| 正定县| 巴彦淖尔市| 赫章县| 拉萨市| 长垣县| 宜春市| 满洲里市| 白朗县| 开封市| 包头市| 舟曲县| 夏津县| 满洲里市| 盈江县| 武邑县| 慈利县| 枣强县| 黄梅县| 白沙| 盐城市| 定陶县| 错那县| 高雄市| 靖宇县| 松江区| 玉山县| 宁津县| 福清市| 开原市| 乌拉特前旗| 玉龙| 德令哈市| 巴东县|