.

...back to the entrance

● フレーム仕立てにするときのTips 2004-09-29
フレーム仕立てにしてみた。左フレームに固定メニュー(menu.htm)、右フレームに目次(index.html)、各記事は右フレームを切り替えて表示。
フレーム仕立ての宿命だが、検索エンジンや他のページのリンクから飛んでくる場合、framesetのあるurl(ここの場合は http://t-office.raputax.com/index.html)が指定されていないかぎりフレーム構成にはならない。そこでJavaScriptを使って意図したとおりに表示させる。

1) メニューページ(本来の左フレーム)のみまたは目次ページ(本来の右フレーム)のみが表示されるケース
body タグ内に次のスクリプトを記述して index.html に飛ばす。
onload="if(top.length==0){location.href='index.html'}"
2) 各記事のページ(本来の右フレーム)のみが表示されるケース
index.html に飛ばし、右フレーム(name="main")に当該記事を表示する。そのために、 まず当該ファイルの body タグ内に次のスクリプトを記述する( xxx の箇所には index.html の相対パスを入れる)。
onload="if(top.length==0){top.location.href='xxx?'+location.pathname}"
つぎに index.html に下記のスクリプトを追加して
<script type="text/javascript">
<!--
function makeframe(){
      notframe=location.search.substring(1);
      if(notframe!=""){
            frames["main"].location.href=notframe;
      }
}
//-->
</script>
frameset タグ内に次のスクリプトを記述する。
onload="makeframe()"

...to the top