问题标签 [hashbang]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
facebook-opengraph - 整理 Ajax URL
在测试 linting Ajax URL 时,我注意到一个奇怪的行为。可以在http://jankrems.de/hashbang/#!/foo.php找到一个简单的技术测试
当我直接 lint http://jankrems.de/hashbang/foo.php时,一切正常:http ://cl.ly/3f3t2c0i3M3t0x2Q1Z3l
当我 lint Ajax-Url http://jankrems.de/hashbang/#!foo.php有一些非常奇怪的输出:http ://cl.ly/3n3e0r1s122Q1L0U033k
我尝试对 Twitter hashbang-Urls 进行 linting,它们得到了正确处理。我使用的代码非常简单。在 index.php 中有一个转发...
在 foo.php 中,我只输出 Open Graph 标签...
也许我只是瞎了眼,错过了一些明显的东西。
php - 通过动态内容有效使用 Hashbang、JavaScript、PHP 和 AJAX
我一直在为我开始开发的桌面应用程序组合一个网页,我真的很想利用 HTML5 技术和 JavaScript 的动态内容。基本上,如果一个人在他们的浏览器中访问“根”页面(index.php,或只是目录名称),信息、关于、常见问题解答和联系表格的部分都将可见(联系表格除外;点击其部分的标题将触发一个 jQuery 动画来显示它)。在页面的左侧,我有一个基本导航,其中包含指向主页、关于、常见问题和联系方式的链接。这些链接的锚点是“#!/home”、“#!/about”、“#!/faq”和“#!/contact”(分别)。单击其中之一时,JavaScript/jQuery 将隐藏除页眉、页脚、以及 hashbang 所属的部分(对于联系表单,它还将删除该部分标题的点击处理程序,因为当它是唯一的内容时,它不需要也不应该被隐藏这页纸)。目前我正在使用这个:
我几乎可以肯定有更好的方法可以做到这一点,而且我还想确保该页面及其动态内容可以被 Google 的机器人正确抓取。我应该使用 PHP 来正确执行此操作吗?怎么会这样?
谢谢!
javascript - 谷歌会将 hashbang/escaped_fragment 内容的正确 URL 编入索引吗
我最近阅读了 Google 的使 AJAX 应用程序可抓取,因为我想知道如何正确地为 SEO 准备使用 hashbang 导航的动态网站。我现在明白了, mysite.com/#!/foobar
我应该在mysite.com/?_escaped_fragment_=foobar
.
我只是想知道谷歌是否正确地将我的页面索引为http://example.com/#!/foobar
或者它是否使用了这个escaped_fragment
url?我假设(但想确定)它会正确使用我的 hashbang url 来搜索结果,但索引的内容是从escaped_fragment
页面中获取的。
一些确认会帮助我睡得更好。谢谢
javascript - 灵活的 JavaScript 单页应用程序的路由?
我正在构建一个单页网络应用程序(因为我希望在跨页面/状态移动时具有灵活性和速度),但我正在努力解决路由/网址......
在传统的范例中,我会有如下网址:
现在我想用一个为相应路由加载模板和控制器的路由器(例如使用 Backbone)替换它。
我正在考虑使用一个 pages 对象来存储必要的页面信息:
使用路由器,我现在想加载正确的内容和页面状态,给定如下 URL:
example.com/#!/tools/population-tool/?currentYear=1950
如果不使用 Hashbang,或者像这样:
example.com/tools/population-tool/?currentYear=1950
您将如何组织此路由以使 url 方案有意义,同时仍然灵活并允许重定向和新的查询字符串参数?
javascript - 超级鱼和哈希棒
我正在考虑在我的公共网站上用 hashbangs 替换查询字符串,以获得更好的性能。
像 Superfish 这样的菜单是否与 hashbang 兼容?当我单击只有哈希部分不同的菜单项时,如何触发内容更新?
javascript - 有没有办法检测最后一个导航事件是由后退还是前进浏览器按钮引起的?
我正在编写一个使用 HTML5 推送状态(回退到哈希标签)来处理客户端导航的单页 Web 应用程序。
我注意到的一件事是,如果用户向下滚动页面然后单击指向另一个页面的链接,当他们导航到该页面时,浏览器仍将保持在滚动位置。
我想要的是,如果您转到新页面,它会平滑地将您滚动到顶部(与所有网站在跟随链接时的行为相同)。
我在我的导航控制器中通过一个小 jquery 动画实现了这一点,我现在遇到的问题是,如果您单击浏览器后退按钮,您将不会最终处于您之前所在的滚动位置,而是您将在上一页但是您将被滚动到顶部。
是否可以检测上一个/当前客户端导航是否是由浏览器的后退或前进按钮引起的?如果是这样,我将使用它来防止滚动。
干杯
javascript - Catch "Back" event in browser and load different content
I've been working on a project using the hashbang (#!
) method to skip though pages. Basically there is only 1 page, and when you click to go to a diffrent page, you stay on the page, but the URL changes, e.g. from index.html#home
to index.html#about
and new content is loaded via AJAX/JSON. All works well, but if I go "back" (or forward) in the browser, only the page in the URL changes, but my jQuery isn't fired to reload the content.
What I need is some code that will handle both the back and forward actions in all browsers, so that I can fire the function to load the page from jQuery. How do I do this?
javascript - Internal Links with jQuery Address
I'm trying to implement the lovely Address plugin to handle internal links for prettier links and use of the back button. I managed to get it to work, however the one thing I noticed, is that when it changes the URL from /#section to /#/section if the user then copies that URL and tries to open it in a new window (or send to a friend) it does not take the user to that section on the page. Obviously because it's not recognized as an anchor anymore.
How can I get it to be on the right section when a user navigates via the URL?
Below is the snippet of code I'm using in accordance with jQuery Address:
Also here is the link to see it in action: http://nickdimatteo.com/kjd
ajax - 为 SEO 的 hash-bang URL 放置什么 HTML 快照?
我在我的 AJAX 应用程序中使用 hash-bang URL,并且我正在实现服务器端:
处理 ?_escaped_fragment_=key1=value1%26key2=value2
所以当我查看 Google 的FAQ时,它说这个 URL有一个等效的快照
很容易看出,快照内容与对应的 hash-bang url 不一样。这个谷歌示例没有帮助,因此我的问题是:
我的 HTML 页面包含三个由 AJAX 更新的组件/面板/部分。我使用onclick
hash-bang URL 上的事件从服务器获取内容,然后更新 HTML 页面的相关部分。我的面板相互独立更新,每个面板都有自己的 hash-bang URL。
我的问题是:
HTML 快照应该包含包含所有 3 个部分的整个页面还是仅包含更新的部分?
如果我要返回整个页面,几乎不可能正确获取其他 2 个部分的状态,那么如果其他 2 个部分以其默认状态返回,Googlebot 会拒绝我的网站吗?