現在の html ページ (system_details.html) の div セクションにジャンプするために JavaScript 関数を使用しています。
<a href="javascript:show_processor()">Processor</a>
<a href="javascript:show_ram()">RAM</a>
show_ram()
ただし、別のhtmlページ(index.html)からsystem_details.htmlページの機能に直接移動したい
現在の html ページ (system_details.html) の div セクションにジャンプするために JavaScript 関数を使用しています。
<a href="javascript:show_processor()">Processor</a>
<a href="javascript:show_ram()">RAM</a>
show_ram()
ただし、別のhtmlページ(index.html)からsystem_details.htmlページの機能に直接移動したい
リンクと id を指定し<a href="javascript:show_ram()" id="ram">RAM</a>
ます。id
so のようなハッシュを使用して、これを URL の末尾に追加しますindex.html#ram
。
次に、jQueryを使用して次のようにします。
$(document).ready(function(){
if(window.location.hash) $('#' + window.location.hash).click();
});
id
これは、クリックするリンクのとしてハッシュの後の URL の最後の部分を取得click()
し、指定された でリンクを呼び出しますid
。
ajax の概念を使用します。index.html ページからデータを読み込む