FlyPig

          if{}else if{}生活只有一個分支
          posts - 11, comments - 9, trackbacks - 0, articles - 4
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          從一個框架頁向另一個框架頁寫內容

          Posted on 2005-06-16 22:40 FlyPig Lin 閱讀(331) 評論(0)  編輯  收藏 所屬分類: 腳本

          今天做了一個例子,是在一個框架頁里面寫另外兩個框架頁的內容,框架頁是這樣的:
          frame.html:

          <frameset?rows="15%,*"?cols="*"?framespacing="0"?frameborder="1"?id="out">
          ??
          <frame?src="top.html"?name="topFrame"?scrolling="no"?frameborder="1">
          ??
          <frameset?rows="*"?cols="20%,*"?framespacing="0"?frameborder="1"?id="in">
          ????
          <frame?src="left.html"?name="leftFrame"?scrolling="no"?>
          ????
          <frame?src="right.html"?name="rightFrame"?scrolling="no"?>
          ??
          frameset>
          frameset>

          ?

          其中top.html內容是:

          <html>
          ??
          <head>tophead>
          ??
          <body?onLoad="alert('top?load?finish');">
          ??
          <script>

          ????function?writeFrame(frameName,content)
          {?
          ??????
          if(parent.frames[frameName].document?!=?null){
          ????????
          if(parent.frames[frameName].document.body?!=?null){
          ??????????parent.frames[frameName].document.body.innerHTML?
          =?content;
          ????????}
          else{
          ??????????window.setTimeout(
          "writeFrame('"+frameName+"','"+content+"')",1000);
          ????????}

          ??????}
          else{?
          ????????window.setTimeout(
          "writeFrame('"+frameName+"','"+content+"')",1000);
          ??????}

          ?????}


          ?????
          ?????function?writeFrameDirect(frameName,content)
          {
          ????????
          if(parent.frames[frameName].document?!=?null)
          ????????????
          if(parent.frames[frameName].document.body?!=?null)
          ????????????????parent.frames[frameName].document.body.innerHTML?
          =?content;
          ?????}


          ?????function?a()
          {
          ????????writeFrame(
          'leftFrame','top?write?left');?
          ????????writeFrame(
          'rightFrame','top?write?right');?
          ?????}


          ?????function?b()
          {
          ????????writeFrameDirect(
          'leftFrame','top?write?left');?
          ????????writeFrameDirect(
          'rightFrame','top?write?right');?
          ?????}


          ?????a();
          ?????
          //b();
          ??script>

          ??
          body>
          html>

          left.html內容是:
          <html>
          ??
          <head>head>
          ??
          <body?onLoad="alert('left?load?finish');">
          ??
          body>
          html>

          ?

          right.html內容是:

          <html>
          ??
          <head>head>
          ??
          <body?onLoad="alert('right?load?finish');">
          ??
          body>
          html>

          ?

          雖然明明框架頁onLoad的時候可以看出順序是:left,right,top.可是在top里面如果調用方法b()而不調用方法a(),那從top往left和right寫東西都是不起作用的.很奇怪哪.今天做一個菜單就是遇到這個問題.我要從top往left寫二級菜單的內容,可是調用b()卻寫不成,還好寶玉教了我writeFrame的方法.用setTimeout定時去查left或right加載完畢沒,完畢后才寫.非常感謝他的幫助.

          主站蜘蛛池模板: 盐源县| 全州县| 孟州市| 呼伦贝尔市| 屯门区| 天门市| 化州市| 绥德县| 台中县| 合水县| 平安县| 宁河县| 大兴区| 汉中市| 苏尼特左旗| 定边县| 祁东县| 吉安市| 南投县| 台山市| 辉南县| 合阳县| 高安市| 屯留县| 百色市| 凉山| 桂阳县| 新源县| 淮滨县| 皮山县| 句容市| 民权县| 罗城| 铜陵市| 连平县| 县级市| 玛纳斯县| 台东县| 同江市| 正镶白旗| 北安市|