- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
任何人都可以为 history.replaceState 提供一个工作示例吗?这就是w3.org说:
history.replaceState(data, title [, url ] )
Updates the current entry in the session history to have the given data, title, and, if provided and not null, URL.
这非常有效:
history.replaceState( {} , 'foo', '/foo' );
URL 在变,但标题没有变。那是错误还是我遗漏了什么?在最新的 Chrome 上测试。
最佳答案
确实这是一个错误,尽管现在已经有意为之 2 年了。问题在于一些不明确的规范以及涉及 document.title
和后退/前进时的复杂性。
请参阅 Webkit 上的错误引用和 Mozilla .还有Opera关于History API的介绍said it wasn't using the title parameter并且可能仍然没有。
Currently the 2nd argument of pushState and replaceState — the title of the history entry — isn't used in Opera's implementation, but may be one day.
可能的解决方案
我看到的唯一方法是更改 title 元素并改用 pushState:
document.getElementsByTagName('title')[0].innerHTML = 'bar';
window.history.pushState( {} , 'bar', '/bar' );
关于javascript - history.replaceState() 例子?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12832317/
我在绑定(bind)到 window.hashchange 时遇到问题。调用 history.replaceState 时,除非调用 location.hash,否则它会触发 'hashchange'
我有这个网址: website.com/con?blog=true 我在 javascript 中做的是: if (getURLparams(blog)) { RandomFunction();
我们的单页应用程序使用自定义路由器。我们使用history.replaceState(...)将无效的url替换为有效的url。 网址看起来像... http://domain.com/#view=e
我目前正在使用 Node-RED 开发一个应用程序。我想更改 URL 而不重定向到另一个域。我对基本 JavaScript 有一些经验,并且我知道在 JS 中可以使用 history.replaceS
我一直在阅读和寻找 replaceState() 和 pushState() 之间的优缺点。另请阅读 Mozilla 的 article ,还有这个 interesting进行测试,但我仍然不清楚其中
任何人都可以为 history.replaceState 提供一个工作示例吗?这就是w3.org说: history.replaceState(data, title [, url ] ) Updat
我正在使用 bootstrap 的 scrollspy 更改页面滚动时突出显示的导航栏项目,然后使用 history.replaceState 将哈希添加到 url。 This question给了我
我创建了一个产品列表页面并使用这段 JS 来保持 url 反射(reflect)用户正在查看的项目(因此后退按钮应该返回到页面上的那个点) setInterval(function() { i
有没有什么技术可以用来更新历史状态对象而不是替换它? 给定一个看起来像这样的现有状态对象: { prop1:someValue, prop2:someOtherValue } 我希望能够调用将修改 p
我使用的是 History.js 框架,我只使用了 replaceState 方法。 我的问题是关于 replaceState 行为,因为它替换了所有查询字符串。 History.replaceSta
有什么方法可以在不重新加载的情况下用 JavaScript 替换 url 吗?例如 www.url.com/index.php/presenter/view/../ 到 www.url.com/pre
我正在构建一个显示数据表的组件。当他们向该数据添加和删除过滤器时,我想用 replaceState 修改 queryString,但据我所知,没有方法可以做到这一点。 有没有办法告诉转换使用 repl
我对此快疯了。我已经阅读了我能找到的有关该主题的所有内容,但我迷失了...... 我有一个带有按钮和 2 个 iframe 的页面。 单击该按钮会更改 2 个 iframe 的 URL。 $(d
我正在使用 window.history.replaceState 并遇到一些问题,因为它不断附加到网址。 它已被标记为 this question 的重复项我认为这是一个错误,因为当我使用该代码时,
这个问题在这里已经有了答案: monitoring history.pushstate from a chrome extension (3 个答案) How to detect page navi
当用户访问我网站的根文件夹 (www.mysite.com) 时,我想将网址更改为 www.mysite.com/home。 我正在使用 History.js 来实现此目的,并且我正在使用以下代码:
具体来说,调用下面的代码片段: history.replaceState(undefined, undefined, "#" + value) 不会正确地影响当前页面的后退按钮行为,但会向“浏览历史”
我在所有浏览器中都面临这个问题。每当我尝试在 Google 缓存中查看我的网站时都会出现此问题 main.bundle.js:1 ERROR Error: Uncaught (in promise):
我有一个站点的测试版本位于正常站点的子域中,例如: http://test.x.com而不是 http://x.com . 我使用 将所有资源请求转换回原始域的标记: 在我实现 HTML5 push
我有window.history.replaceState(null, null, 'about');在 main.js位于 required/javascripts在我的服务器上。 然后在关于页面(
我是一名优秀的程序员,十分优秀!