[英]Remove tabindex from google maps v3
我正在嘗試從maps api的所有部分中刪除tabindex,我已經嘗試過這篇文章的答案:
google.maps.event.addListener(MAP, "tilesloaded", function(){
[].slice.apply(document.querySelectorAll('#map a')).forEach(function(item) {
item.setAttribute('tabindex','-1');
});
})
但這是行不通的,我在一個簡單的地圖上嘗試將其添加到應用程序中,因此這是簡單的頁面:
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 50%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<input type="text">
<div id="map"></div>
<input type="text">
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: -34.397, lng: 150.644},
zoom: 8
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?&callback=initMap"
async defer></script>
</body>
</html>
如果您希望地圖不具有交互性,那么使用靜態地圖API似乎是一個合理的選擇
編輯:根據您的評論,如果您不希望非屏幕閱讀器用戶完全正常工作,則可以選擇將地圖插入<div aria-hidden="true">
標記中,該標記應使屏幕閱讀器無法讀取它。 您還可以在地圖上方添加“跳過地圖”鏈接,以使鍵盤用戶(無屏幕閱讀器)繞過地圖。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.