javascript - 如何从标签顺序中删除 Bing 地图(和所有子控件)
问题描述
Bing 地图控件 (Microsoft.Maps.Map) 是否提供 API 用于从选项卡顺序中删除自身(及其子控件)?
或者,是否有适当的回调(渲染后),一旦地图本身呈现,我可以使用递归地在所有元素上设置 tabIndex?
注意:我已经看到在构建时有一些选项可以指定是否呈现地图类型选择器/定位我按钮/缩放按钮。但是让我们假设我们想要渲染这些控件,只需将它们从 Tab 键顺序中删除。
解决方案
我设法使用 MutationObserver 来实现它:
var mapElem = document.getElementById("map");
let deferredClearTabIndexEvent: number | undefined;
if (mapElem !== null) {
var config = { attributes: true, childList: true, subtree: true };
var callback = () => {
if (deferredClearTabIndexEvent === undefined) {
deferredClearTabIndexEvent = window.setTimeout(() => {
var elements = mapElem!.querySelectorAll("a, button, input, select, textarea, [tabindex]")
for (var i=0; i<elements.length; i++) {
elements[i].setAttribute("tabIndex", "-1");
}
deferredClearTabIndexEvent = undefined;
}, 0);
}
};
var observer = new MutationObserver(callback);
observer.observe(mapElem, config);
}
推荐阅读
- python - 回归分类报告(sklearn)
- python - 如何将 Keras CNN 模型部署到 Web 服务?
- macos - launchctl config 用户路径有什么作用?
- symfony - Symfony 依赖注入
- java - 这个向上转换的演示如何工作?
- matlab - 如何将键值对添加到 Containers.Map 对象?
- android - 如何为 android 和 ios 单反应原生 kontaktio
- android - 用户和当前进程都没有 android.permission.USE_FINGERPRINT
- perl - Perl - 如何跳过先前处理中已经读取的行
- abap - 如何以编程方式添加表数据以传输请求?