简体   繁体   English

无法使用 querySelector 获取访问元素?

[英]Can't get access elements with querySelector?

I wish to access elements in a site with javascript and I have been using javascript for quite some time, especially with the querySelector functions.我希望使用 javascript 访问站点中的元素,并且我使用 javascript 已经有一段时间了,尤其是使用querySelector函数。 But for some reason, it won't work in this case;但出于某种原因,在这种情况下它不起作用; whenever I try to access any of the top-level elements, as illustrated below, no elements are found.每当我尝试访问任何顶级元素时,如下图所示,都找不到任何元素。 在此处输入图片说明 Does anyone have an idea about what the problem could be, and maybe even how to fix it?有没有人知道问题可能是什么,甚至可能如何解决?

That's normal, It's because when you use the chrome developer console you can change the document context and in your screen you are inside the iframe.这是正常的,这是因为当您使用 chrome 开发者控制台时,您可以更改文档上下文,并且在您的屏幕中您位于 iframe 内。

You can see it here:你可以在这里看到它:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM