[英]How to show real url on the navigation bar when using <a href=“#” onclick=“funtion('test.php')”>
I tried to open the content pages in using a javascript. 我尝试使用javascript打开内容页面。 So, I don't have to write all the header and footer pages.
所以,我不必编写所有页眉和页脚页面。 However, there is a problem, the url is not show in the navigation bar.
但是,有一个问题,导航栏中没有显示网址。 Are there anyway to make the real url show up in the navigation bar?
反正有没有让真实的网址出现在导航栏中? http://www.page.com/test.php ?
http://www.page.com/test.php ?
<script> function openLink(url) { $( ".contentTable" ).load(url); } </script>
<a id="link1" href="#" onclick="openLink('test.php')">Link</a>
It seems that you need to use the history api of your browser : 您似乎需要使用浏览器的历史记录api:
https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method https://developer.mozilla.org/en-US/docs/Web/API/History_API#The_pushState()_method
An example : 一个例子 :
history.pushState({}, "New page test", "/test.php");
First param is a state, second one a title and the third one your url. 第一个参数是一个状态,第二个是标题,第三个是你的网址。
pushState will add the entry to your history and replaceState will replace your current history state by a new one. pushState会将条目添加到您的历史记录中,而replaceState将用新的状态替换您当前的历史记录状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.