[英]Navigate to div section of a different html page using javascript in href
我正在使用javascript函數跳轉到當前html頁上的div部分(system_details.html):
<a href="javascript:show_processor()">Processor</a>
<a href="javascript:show_ram()">RAM</a>
但是,我想直接從另一個HTML頁面(index.html)導航到system_details.html頁面的show_ram()
函數。
提供鏈接和ID <a href="javascript:show_ram()" id="ram">RAM</a>
。 使用像index.html#ram
這樣的哈希將這個id
添加到URL的末尾。
然后使用jQuery執行以下操作:
$(document).ready(function(){
if(window.location.hash) $('#' + window.location.hash).click();
});
這將把哈希后的URL的最后一部分作為要單擊的鏈接的id
,然后在具有指定id
的鏈接上調用click()
。
使用ajax的概念。 從index.html頁面加載數據
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.