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

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

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

コメントを残す

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

Your post must include a link to this post.

How does this work?
Write a response on your own website and include a link to this post. Then submit your response’s URL here. Your response may appear here after moderation. To update or remove it, edit or delete your original post and submit the same URL again. Learn more about Webmentions.