簡體   English   中英

如何在使用時在導航欄上顯示真實的網址

[英]How to show real url on the navigation bar when using <a href=“#” onclick=“funtion('test.php')”>

我嘗試使用javascript打開內容頁面。 所以,我不必編寫所有頁眉和頁腳頁面。 但是,有一個問題,導航欄中沒有顯示網址。 反正有沒有讓真實的網址出現在導航欄中? http://www.page.com/test.php

 <script> function openLink(url) { $( ".contentTable" ).load(url); } </script> 
 <a id="link1" href="#" onclick="openLink('test.php')">Link</a> 

您似乎需要使用瀏覽器的歷史記錄api:

https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method

一個例子 :

history.pushState({}, "New page test", "/test.php");

第一個參數是一個狀態,第二個是標題,第三個是你的網址。

pushState會將條目添加到您的歷史記錄中,而replaceState將用新的狀態替換您當前的歷史記錄狀態。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM