【发布时间】:2013-02-16 19:13:38
【问题描述】:
代码示例:
无页面导航:
<body>
<nav>
// Navigation links to the parts of the site.
// Clicking a link calls a javascript function to display the relevant <div>
</nav>
<section id="page1">
// Page 1 content
</section>
<section id="page2">
// Page 2 content
</section>
</body>
页面导航:
// Page1.php:
<body>
<nav>
// Navigation links to parts of the site.
// Act as normal <a> tags, redirecting the browser to the new page
</nav>
<section>
// Page1 content
</section>
</body>
// Page2.php:
<body>
<nav>
// Navigation links to parts of the site.
// Act as normal <a> tags, redirecting the browser to the new page
</nav>
<section>
// Page2 content
</section>
</body>
链接导航的优点:
浏览器不需要一次性加载整个网站
无需 javascript 即可使用该网站
提供直接 URL 以便于导航
似乎是标准的做法
javascript 导航的优点:
对于服务器端脚本繁重的网站(如我的),最大限度地减少页面请求
不需要在不同的地方使用相同的代码(例如
<nav>元素)。在 PHP 中创建echo_nav_html()函数并不是一个好的解决方案,因为它会使 IDE 环境中的编码变得烦人初始加载后,站点速度超快,几乎没有任何新请求发送到服务器
哦,聪明的互联网,对此有什么想法吗?
或者也许更优雅的解决方案提供列出的 javascript 导航专家?
【问题讨论】:
标签: php javascript html navigation