更改页面而不将 div 刷新到页面中
您好,我正在寻找一个教程,以了解如何创建一个带有 div 的页面,该页面在页面 url 更改时不会刷新。
前任。当我从一个网址移动到另一个网址时,Facebook 聊天不会刷新。
谢谢
Hi i'm looking for a tutorial for understand how i can create a page with a div that isn't refreshed when the page url changes.
Ex. The facebook chat isn't refreshed when i move from an url to another.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
AJAX 肯定正在被使用,尽管看起来可能不像,因为实际的 URL 正在改变。大多数 AJAX 应用程序只是更改 URL 的哈希部分 (somesite.com/page/#feature1)。
我不知道 Facebook 到底在做什么,因为我还没有研究过这个应用程序,但我猜他们正在使用 HTML5
history.pushState()
来更改 URL,以便您将其添加为书签或重新加载,它会去同一个地方。我看到 @Felix 已经在评论中提到了这一点。请查看此处以获取更多帮助:
有没有办法更改浏览器的地址栏而不刷新页面?
有很多很多关于使用 AJAX 的资源。我个人使用 jQuery,发现它使这一切变得非常简单。这是一个可能有帮助的教程:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
AJAX is definitely being used, although it may not seem like it because the actual URL is changing. Most AJAX apps just change the hash part of the URL (somesite.com/page/#feature1).
I don't know exactly what Facebook is doing as I haven't studied the app, but I would guess that they are using HTML5
history.pushState()
to change the URL so that if you bookmark it or reload, it will go to the same place. I see that @Felix already mentioned this in a comment.Take a look here for more help:
Is there a way to change the browser's address bar without refreshing the page?
There are lots and lots of resources on using AJAX. I personally use jQuery and find that it makes much of this quite easy. Here's a tutorial that might help:
http://net.tutsplus.com/tutorials/javascript-ajax/5-ways-to-make-ajax-calls-with-jquery/
听起来您想使用 AJAX (javascripts XMLHttpRequest 函数)。这是一篇关于它的精彩文章以及一些基本示例:此处
Sounds like you are wanting to use AJAX (javascripts XMLHttpRequest function). here is a great article on it along with some basic examples: Here
它被称为 AJAX,如果您使用 jQuery,这里有一个很好的教程:
http://yensdesign.com/2008/11/creating-ajax-websites-based-on-anchor-navigation/
如果您不使用 jQuery,我想发布另一个示例,但我需要更多的点来发布不止一个链接,抱歉...
It's called AJAX, if you use jQuery, here's a good tutorial:
http://yensdesign.com/2008/11/creating-ajax-websites-based-on-anchor-navigation/
I wanted to post another examples if you dont use jQuery but i need more points to post more than one link, sorry...