0

我正在使用 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 页面的功能

4

2 回答 2

0

给出链接和 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

于 2013-04-18T04:36:07.470 回答
-1

使用 ajax 概念。从 index.html 页面加载数据

于 2013-04-18T04:34:12.947 回答