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加載完畢沒,完畢后才寫.非常感謝他的幫助.

          主站蜘蛛池模板: 巢湖市| 胶南市| 龙泉市| 开原市| 恩平市| 区。| 溧阳市| 二连浩特市| 光泽县| 定远县| 财经| 沾化县| 维西| 进贤县| 竹山县| 富源县| 西贡区| 太谷县| 霍邱县| 搜索| 鸡西市| 金溪县| 嘉兴市| 武义县| 东乡族自治县| 定陶县| 土默特左旗| 汤原县| 浪卡子县| 宝兴县| 宁阳县| 赣州市| 门头沟区| 南昌市| 盐源县| 朔州市| 广德县| 黄龙县| 西丰县| 望江县| 佳木斯市|