FlyPig

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

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

          Posted on 2005-06-16 22:40 FlyPig Lin 閱讀(335) 評論(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加載完畢沒,完畢后才寫.非常感謝他的幫助.

          主站蜘蛛池模板: 虞城县| 丰县| 什邡市| 太湖县| 若尔盖县| 沙坪坝区| 扶余县| 自治县| 县级市| 获嘉县| 宿州市| 都江堰市| 镶黄旗| 巫山县| 治多县| 沁源县| 长春市| 巴彦淖尔市| 都兰县| 岗巴县| 庆城县| 会理县| 宝兴县| 红安县| 邵东县| 龙泉市| 江山市| 吴桥县| 大兴区| 南宫市| 长武县| 仲巴县| 保康县| 伊金霍洛旗| 元谋县| 兴隆县| 京山县| 四川省| 平罗县| 岢岚县| 兴城市|