想要从表中获取所有元素 [英] Want to get all elements from the table

查看:34
本文介绍了想要从表中获取所有元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站登录: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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆