如何实现点击内部链接URL不改变的网站?

发布于 2024-08-09 20:47:13 字数 199 浏览 4 评论 0原文

有些网站如何实现点击内部链接时URL地址不改变的?例如,如果 URL 是 www.example.com,那么当您单击该网站的“联系方式”链接时,它仍然保持不变。此外,当我访问我的网站时,它会更改为 www.example.com/home.html,但其他一些网站仍保留 www.example.com

How do some website implement URL addresses that don't change when you click on an internal link? So if, for example, the URL is www.example.com it remains exactly that if you clicked on the "contact" link of that site. Also when I go to my site it changes to www.example.com/home.html but some other site remain www.example.com.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

许仙没带伞 2024-08-16 20:47:14

其他选项包括 AJAX 或 JavaScript 实现。

例如,使用 AJAX,您可以将动态信息加载到元素(例如 DIV)中,而不会导致页面重新加载。

使用其他 JavaScript 功能也可以这样说,例如通过附加到链接的 onclick 事件隐藏和显示页面上的元素。

正如马丁上面所说,这种功能绝对被认为是不好的做法。您基本上会杀死用户或搜索蜘蛛将寻找的任何类型的网站结构。

Other options include AJAX or JavaScript implementations.

For instance, with AJAX you can load dynamic information into an element (such as a DIV) without causing the page to reload.

The same can be said of using other JavaScript functionality, for instance hiding and showing elements on the page via an onclick event attached to a link.

As Martin said above, this sort of functionality is definitely considered to be bad practice. You essentially kill any sort of site structure that either a user or search spider will be looking for.

紫竹語嫣☆ 2024-08-16 20:47:14

简单的 iframe 示例(demo):

<html> 
  <head> 
    <title>CNN</title> 
    <style type="text/css">       
      html, body, iframe {
        margin: 0px;
        padding: 0px;
        height: 100%;
        width: 100%;
        border: none;
        overflow: hidden; }
      iframe { overflow: auto; }
    </style> 
  </head> 
  <body> 
    <iframe src="http://www.cnn.com/"></iframe> 
  </body>
</html> 

正如其他人已经指出的那样,这是这是一个不好的做法。

Simple iframe example(demo):

<html> 
  <head> 
    <title>CNN</title> 
    <style type="text/css">       
      html, body, iframe {
        margin: 0px;
        padding: 0px;
        height: 100%;
        width: 100%;
        border: none;
        overflow: hidden; }
      iframe { overflow: auto; }
    </style> 
  </head> 
  <body> 
    <iframe src="http://www.cnn.com/"></iframe> 
  </body>
</html> 

As others have already stated this is a bad practice.

蓝眸 2024-08-16 20:47:13

可能只使用框架或 iframe。 www.example.com 上的外框架保持不变,而内框架指向 www.example.com/home 或其他内容。

The probably just use frames or iframes. The outer frame on www.example.com stays in place while the inner frame points to www.example.com/home or whatever.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文