Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/375.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在href中使用javascript导航到其他html页面的div部分_Javascript_Html - Fatal编程技术网

在href中使用javascript导航到其他html页面的div部分

在href中使用javascript导航到其他html页面的div部分,javascript,html,Javascript,Html,我正在使用javascript函数跳转到当前html页面(system_details.html)上的div部分: 但是,我想从另一个html页面(index.html)直接导航到system_details.html页面的show_ram()函数使用ajax概念。从index.html页面加载数据给出链接和id。使用类似于soindex.html#ram的散列将此id添加到URL的末尾 然后使用来执行以下操作: $(document).ready(function(){ if(wind

我正在使用javascript函数跳转到当前html页面(system_details.html)上的div部分:



但是,我想从另一个html页面(index.html)直接导航到system_details.html页面的
show_ram()
函数使用ajax概念。从index.html页面加载数据

给出链接和id
。使用类似于so
index.html#ram
的散列将此
id
添加到URL的末尾

然后使用来执行以下操作:

$(document).ready(function(){
  if(window.location.hash) $('#' + window.location.hash).click();
});

这将把散列后URL的最后一部分作为要单击的链接的
id
,然后用指定的
id
调用链接上的
click()

我已经更新了答案,因为我意识到我没有正确理解原始问题。
$(document).ready(function(){
  if(window.location.hash) $('#' + window.location.hash).click();
});