我正在使用 javascript 函数跳转到当前 html 页面(system_details.html)上的 div 部分:
<a href="javascript:show_processor()">Processor</a>
<a href="javascript:show_ram()">RAM</a>
但是,我想show_ram()
从不同的 html 页面(index.html)直接导航到 system_details.html 页面的功能
我正在使用 javascript 函数跳转到当前 html 页面(system_details.html)上的 div 部分:
<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
到 URL 的末尾index.html#ram
。
然后使用jQuery做这样的事情:
$(document).ready(function(){
if(window.location.hash) $('#' + window.location.hash).click();
});
这会将散列后的 URL 的最后一部分作为id
要单击的链接的 ,然后调用click()
具有指定 的链接id
。
使用 ajax 概念。从 index.html 页面加载数据