Đang chuẩn bị liên kết để tải về tài liệu:
build your own ajax web applications PHẦN 9

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

"hackishness." Giải pháp của kết quả cuối cùng sẽ không làm việc tốt với công nghệ hỗ trợ như các trình đọc màn hình, và sẽ không làm việc trong Safari. Tóm lại, sửa chữa các công trình như thế này: ❑ Store vị trí lịch sử địa chỉ của trang web sau khi băm thường được dành riêng để di chuyển nội bộ (ví dụ, mypage.html # Section1). | Using the Location Hash the solution s hackishness. The end result will not work well with assistive technology like screen readers and won t work in Safari at all. In short the fix works like this Store the history position in the page s address after the hash that s usually reserved for internal page navigation e.g. mypage.html section1 . Run a process on a timer that synchronizes the page state with what it sees in the page address. The Hash The part of a web address that appears after the pound or hash sign is known by many names. Here we ll refer to it as the hash. Using the Location Hash This solution works because the browser history tracks all changes to the page address including changes to the hash. So if you set it up right as you run your searches the page URI displayed in the location bar will change like so webservices2.html webservices2.html 0 webservices2.html 1 webservices2.html 2 webservices2.html 3 This allows users to click back and forth in the normal browser history and pull up the appropriate search history entry. Breaking Accessibility Because this fix co-opts the internal navigation hash to store the search-history position internal links such as skip navigation links will break this technique. Setting Up the Fix Way back when we added the init method to our Search class we set it up to call startHist when BROWSER_BACK was set to true. This startHist method sets up some of the IE-specific stuff for us and activates the process we ll be using 235 Licensed to siowchen@darke.biz Chapter 7 More Web Services and a Back Button to synchronize the history state to the one that s indicated in the browser s location bar. Here s the code File webservices2.js excerpt this.startHist function var self Search var href var ifr null if document.all ifr document.createElement iframe ifr.name historyFrame ifr.id historyFrame ifr.src ifr.style.display none document.body.appendChild ifr if location.hash href location.href.split 0 location href setInterval .