मैं अंत में यह समझ से बाहर। मैं मूल रूप से
- पड़ा हैश से निपटने के लिए इस्तेमाल किया ढांचा/लिपि अक्षम बदलता है
- बदलें यूआरएल मुख्य सामग्री को इंगित करने के
- मूल URL पुनर्स्थापित करें और पुन: सक्षम मैं # 1 में क्या अक्षम ।
उदाहरण के लिए, मैं इस तरह की एक घटना थी:
var onPageChange = function (newLocation, historyData) {
// load page
};
पहले, मैं यह करने के लिए बदल दिया है:
var pageChangeEnabled = true;
var onPageChange = function (newLocation, historyData) {
if (pageChangeEnabled) {
// load page
}
};
और फिर, Skip Navigation
लिंक इस तरह दिखता है:
<a href="javascript:pageChangeEnabled=false;var oh=location.hash;location.hash='#content';location.hash=oh;pageChangeEnabled=true;void(0);" id='skipNav'>Skip Navigation</a>
आसान समझने के लिए, यहमें कोड है:
// disable navigation
pageChangeEnabled=false;
// save current hash
var oldHash=location.hash;
// update the hash/anchor, make everything work
location.hash = '#content';
// restore the old hash, as there are no elements that have the same
// name of the URL, it works
location.hash = oldHash;
// re-enable page navigation
pageChangeEnabled=true;
// void(0); is just to avoid the navigation of the link
void(0);
अद्यतन: एडम द्वारा समझाया रूप में, यह पूरी तरह से काम नहीं करता है के रूप में कीबोर्ड नेविगेशन नहीं बदलता है। मैं कर रहा हूं: $('#content').attr('tabindex', '-1').focus();
स्रोत
2015-11-11 18:40:33
क्या आप एसपीए ढांचे का उपयोग कर रहे हैं? रूटिंग को संभालने के तरीके के बारे में जानकारी जानना उपयोगी होगा। उदाहरण के लिए कुछ [कोणीय के लिए संभावित समाधान] (http://stackoverflow.com/questions/14712223/how-to-handle-anchor-hash-linking-in-angularjs) उपयोगकर्ता हैं। – Jasen
@ जेसन नहीं, मैं नहीं हूं।मैं ब्राउजर इतिहास को संभालने के लिए एक साधारण जेएस लाइब्रेरी का उपयोग कर रहा हूं, लेकिन यह है। आपके द्वारा डाले गए उदाहरण में मैं जो देख सकता हूं वह यह है कि यह केवल स्क्रॉल करता है, लेकिन कीबोर्ड नेविगेशन या स्क्रीन पाठकों के साथ अच्छा काम नहीं करता है। –