简体   繁体   English

如何链接到页面并在页面之间导航而不重新加载页面?

[英]How to link to pages and navigate between them without reloading them?

I'm developing a site heavily based on jQuery and involving WordPress. 我正在开发一个高度基于jQuery并涉及WordPress的网站。 Is there any way to navigate between pages without reloading the whole thing, other than simple hide/show functions? 除了简单的隐藏/显示功能之外,还有什么方法可以在页面之间导航而不重装整个东西? Or with hide/show how can I link to a certain part of the site? 或者通过隐藏/显示如何链接到网站的特定部分?

For example if the home page is a heap of divs 例如,如果主页是一堆div

<div id="1">
    <p>content here</p>
</div>

<div id="2">
    <p>more content here</p>
</div>

By default div 1 is shown and 2 hidden, but how could I load up the page with div 2 showing for example if someone wants to bookmark it? 默认情况下,显示div 1并隐藏2,但是如何加载显示div 2的页面,例如显示某人是否要为其添加书签?

I could have a copy of the markup as a separate file with the onload hide/show different for each one, and use the same coding file for functionality. 我可以将标记的副本作为一个单独的文件使用,每个onload的隐藏/显示都不同,并使用相同的编码文件来实现功能。

Would this work, and any tips? 这行得通,还有任何提示吗?

Would it be better to build just a regular site? 只建立一个常规站点会更好吗?

Im not quite sure I fully understand you question, but JQuery does make it easy to use Ajax to load content from your server asynchronously. 我不太确定我是否完全理解您的问题,但是JQuery确实使使用Ajax轻松地从服务器异步加载内容变得容易。 You can find documentation here . 您可以在此处找到文档。

I am not aware of any way to bookmark the state of an HTML document after it has been dynamically modified by JavaScript (except for something called session state that is lost when the window is closed), but there are ways to do bookmarking when you use Ajax. 我不知道有任何方法可以用JavaScript对HTML文档的状态进行修改后将其标记为书签(除了在关闭窗口时会丢失的称为会话状态的东西),但是有一些方法可以在使用时添加书签阿贾克斯

I have never tried to bookmark with Ajax, and I am pretty sure that JQuery doesn't have this functionality built in. 我从未尝试使用Ajax进行书签,而且我很确定JQuery不会内置此功能。

I don't have never tried bookmarking with Ajax myself, but I found this article which looks very promising. 我从未尝试过自己用Ajax进行书签,但是我发现这篇文章看起来很有希望。

My opinion is that if the content is significant enough to merit being bookmarked, it probably needs to be built the regular way. 我的意见是,如果含量足够显著功德被书签,它可能需要建立正规途径。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Web 开发:如何在浏览器中“存储”页面并防止它们每次在浏览器之间导航时重新加载 - Web development: How to 'store' pages in the browsers and prevent them from reloading every time when navigating between them 在页面之间导航而不更改链接 - Navigate between pages without changing the link 在两个PHP文件或页面之间导航,而无需重新加载 - Navigate between two PHP files or pages without reloading 如何在不使用 ReactJS 指定所有页面的情况下生成页面 - How to generate pages without specifying all of them with ReactJS 在页面之间共享组件而无需重新加载 - share component between pages without reloading it 如何匹配所有内部星号,它们之间没有空格 - How to match all inside asteriks without spaces between them 如何在 React JS 中的两个页面之间导航 - How to navigate between two pages in React JS 如何在离子的两个页面之间导航 - how to navigate between two pages in ionic 如何导航到我网站的另一个页面而无需重新加载php中的标头 - how to navigate to another page of my website without reloading header in php 如何在不重新加载所有资源的情况下在移动应用中导航? - how to navigate in a mobile app without reloading all resources?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM