Tìm kiếm hỗ trợ

Tránh các lừa đảo về hỗ trợ. Chúng tôi sẽ không bao giờ yêu cầu bạn gọi hoặc nhắn tin đến số điện thoại hoặc chia sẻ thông tin cá nhân. Vui lòng báo cáo hoạt động đáng ngờ bằng cách sử dụng tùy chọn "Báo cáo lạm dụng".

Learn More

Event hashchange and document.title

  • 1 trả lời
  • 1 gặp vấn đề này
  • 7 lượt xem
  • Trả lời mới nhất được viết bởi 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?

Tất cả các câu trả lời (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/.