想要从表中获取所有元素 [英] Want to get all elements from the table
问题描述
我有一个网站登录:cyclefreight1@usa.compas:12345678,登录并进入驱动程序部分(左侧菜单栏第一项>驱动程序)我想用 tampermonkey 为这个网络做一些额外的功能,我尝试从表格中获取所有元素,我用这样的选择器来做
i have a website login: cyclefreight1@usa.com pas: 12345678, log in and go to the drivers section(left menu bar firs item > drivers) I want to make some additional function to this web with tampermonkey, i try to get all elements from the table, i do it with selector like this
var rows = document.querySelectorAll("#app table.table-component tr");
但我所拥有的都是未定义的 ^( ,请给我一些提示,我该怎么做,谢谢
but all i have is undefined ^( , please give me some tips how can i do it, thank you
推荐答案
该表位于另一个域的 iframe
内,因此访问起来很棘手.在那个other域中包含用户脚本,并给它一个 setTimeout
以给表格填充时间:
The table is inside an iframe
on another domain, so it's tricky to access. Include the userscript on that other domain, and give it a setTimeout
to give the table time to populate:
// ==UserScript==
// @name drivers
// @match https://eldclient.trackingmap.eu/drivers*
// @grant none
// ==/UserScript==
setTimeout(() => {
const rows = document.querySelectorAll("#app table.table-component tr");
console.log(rows);
}, 2000);
这篇关于想要从表中获取所有元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!