搜索 | 用户支持

防范以用户支持为名的诈骗。我们绝对不会要求您拨打电话或发送短信,及提供任何个人信息。请使用“举报滥用”选项报告涉及违规的行为。

Learn More

Event hashchange and document.title

  • 1 个回答
  • 1 人有此问题
  • 10 次查看
  • 最后回复者为 Paul

more options

I have a problem with some JavaScript code that is run on a hashchange event.

The code updates the web document, and also the document.title. The document.title is modified last.

If not modifying document.title, everything works fine. If updating document.title, the code sometimes fails, but not always. The symptoms are as follows.

  • The document.title is updated correctly, according to the A-tag with the hash URL that was clicked.
  • The URL field in the browser is not updated to the new value.
  • Non of the other document updates are done, even if they are performed on the code lines before changing document.title.

If a move the mouse outside Firefox and click in another window, the browser URL field is updated and the rest of the document is updated.

I then tried the code in google-chrome. There everything works fine.

If I add a console.log() in the hashchange eventhandler, everything works fine. Another work-around is to use window.setTimeout and delay modification of document.title by e.g. 10ms.

Is this a problem in Firefox, or am I not supposed to modify document.title on the hashchange event?

I am using Firefox 88.01 for Fedora 33.

I guess I should not include HTML and JavaScript in this editor?

I have a problem with some JavaScript code that is run on a hashchange event. The code updates the web document, and also the document.title. The document.title is modified last. If not modifying document.title, everything works fine. If updating document.title, the code sometimes fails, but not always. The symptoms are as follows. * The document.title is updated correctly, according to the A-tag with the hash URL that was clicked. * The URL field in the browser '''is not''' updated to the new value. * Non of the other document updates are done, even if they are performed on the code lines before changing document.title. If a move the mouse outside Firefox and click in another window, the browser URL field is updated and the rest of the document is updated. I then tried the code in google-chrome. There everything works fine. If I add a console.log() in the hashchange eventhandler, everything works fine. Another work-around is to use window.setTimeout and delay modification of document.title by e.g. 10ms. Is this a problem in Firefox, or am I not supposed to modify document.title on the hashchange event? I am using Firefox 88.01 for Fedora 33. I guess I should not include HTML and JavaScript in this editor?

所有回复 (1)

more options

Hi

This does not sound like a Firefox issue, more of a web development question. I recommend that you ask the experts in this at: https://stackoverflow.com/.