javascript - 如何防止 iframe 显示具有特殊类名的元素?
问题描述
我目前正在尝试在 iframe 中为我的客户显示 matomo 仪表板。iframe 中有一些我不想显示的元素。
这是我尝试过的:
function removeSegmentedLog(){
var segmentedlog = document.getElementById('iframe').contentWindow.document.getElementsByClassName('actionSegmentVisitorLog');
console.log(segmentedlog);
for (let j = 0; j <= segmentedlog.length; j++) {
document.getElementById('iframe').contentWindow.document.getElementsByClassName('actionSegmentVisitorLog')[j].remove();
console.log('remove');
}
}
该函数在 iframe 元素的 onload 时调用。
控制台有时会说没有元素,但它们就在那里。
有什么方法可以防止 iframe 显示任何类名为 'actionSegmentVisitorLog' 的元素?
解决方案
推荐阅读
- r - 如何为这些回归创建一个循环?
- unit-testing - Mockito 方法调用存根不起作用 - Mockito.doReturn(false).when(studentServiceImpl).myClass().isValidUser(ArgumentMatchers.anyInt());
- python - Python:使用文件夹名称作为键,文件名作为值来制作字典
- java - 在 POSTMAN 中使用 JSON 传递变量时间戳
- python - 如何在python中将JSON字符串转换为整数?
- asp.net-core - 扩展为的方法
- ...
表达 - javascript - 如果网站在 VS2015 中创建为 Visual C# ASP.Net Web 应用程序,则 PageMethods 不起作用
- node.js - 验证码完成后恢复自动化
- reactjs - 如何使反应路由器受到保护?
- git - 如何在 Sourcetree 中取消拉取请求