単一ページのリンクからフレームセットにリンクを張るのん。

フレーム利用したサイトに、メニューやヘッダーを統合した単一ページを設けた場合、他のフレーム利用ページへのリンクをどうするかが問題。
ページごとにフレームセット用意すればええっちゅうはなしやけど、そんなんめんどいし、
なんか方法ないかと探ったところ。
リンク先での変更がコンテンツ部分だけなら、
リンク元ページからヘッダ、メニュー、コンテンツと切り出したフレームを呼び出して、そいつのコンテンツ部分をlocation.sarchやlocation.hashでリンク元ページから取得すればOK。

location.hashにするなら、、リンク元ページのリンクで

<a href=”frame.html#contents.html”>コンテンツへのリンク</a>

としておいて、リンク先のframe.htmlにjavascriptでフレームを生成。ほんでlocation.hashの文字列を読み込む。

<script type=”text/javascript”>
document.write(‘<frameset rows=”51,1*” frameborder=”0″ framespacing=”0″ border=”0″>’);
document.write(‘<frame src=”header.html” >’);
document.write(‘<frameset cols=”210,1*” frameborder=”0″ framespacing=”0″ border=”0″>’);
document.write(‘<frame src=”menu.html” marginwidth=”0″ marginheight=”0″ name=”main1″ scrolling=”auto” noresize>’);
document.write(‘  <frame src=”‘ + location.hash.substr(1) + ‘” marginwidth=”0″ marginheight=”0″ name=”main” scrolling=”auto”>’);
document.write(‘</frameset>’);
</script>

ちゅう感じ。という覚書。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

To respond on your own website, enter the URL of your response which should contain a link to this post's permalink URL. Your response will then appear (possibly after moderation) on this page. Want to update or remove your response? Update or delete your post and re-enter your post's URL again. (Find out more about Webmentions.)