0

我们正在构建一个 Opera 扩展,在该扩展中我们尝试使用文档对象属性 (document.body.innerHTML) 来获取站点主页的来源。在大多数情况下,它为我们提供了正确的页面源,但对于某些站点(具有多个文档层的站点),它不会返回最顶层的文档。

例如,对于站点 (https://www.pcisecuritystandards.org/),我们希望为显示的主页提供源,但一旦加载了整个页面,文档属性将显示另一层的源 (https ://s7.addthis.com/static/r07/sh29.html#cb=0&ab=-&dh=www.pcisecuritystandards.org&dr=&du=https%3A%2F%2Fwww.pcisecuritystandards.org%2F&dt=Official%20PCI% 20Security%20Standards%20Council%20Site%20-%20Verify%20PCI%20Compliance%2C%20Download%20Data%20Security%20and%20Credit%20Card%20Security%20Standards&inst=1&lng=en&pc=men&pub=&ssl=1&sid=4d2ee1f94278e711b&srd= &srp=0.2&srx=0&ver=250&xck=0&rev=86981&xd=1)

这可能与 Opera 如何在页面中加载文档层有关。我们没有遇到任何其他浏览器的问题

我们如何使用 Opera 中的文档对象获取主页(https://www.pcisecuritystandards.org/)的来源?

4

3 回答 3

1

看起来你可能在一个<iframe>. 注入的脚本将被注入顶部文档以及页面上的任何 iframe,因此在抓取innerHTML. 类似的东西if (window.self == window.top)

于 2011-01-19T16:07:15.260 回答
0

您是否尝试过使用蜻蜓,了解 Opera 正在发生的事情很有用。现在我正在使用 Opera 11,当我转到你提到的页面时。我在 innerHTML 中得到了一些东西。

"<div style="visibility: hidden; height: 1px; width: 1px; position: absolute; z-index: 100000" id="_atssh"><iframe id="_atssh827" style="height: 1px; width: 1px; position: absolute; z-index: 100000; border-top-color: currentColor; border-left-color: currentColor; border-right-color: currentColor; border-bottom-color: currentColor; border-top-width: 0px; border-left-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-top-style: none; border-left-style: none; border-right-style: none; border-bottom-style: none; left: 0px; top: 0px" src="//s7.addthis.com/static/r07/sh30.html#cb=0&amp;ab=-&amp;dh=www.pcisecuritystandards.org&amp;dr=&amp;du=https%3A%2F%2Fwww.pcisecuritystandards.org%2F&amp;dt=Official%20PCI%20Security%20Standards%20Council%20Site%20-%20Verify%20PCI%20Compliance%2C%20Download%20Data%20Security%20and%20Credit%20Card%20Security%20Standards&amp;inst=1&amp;lng=fr&amp;pc=men&amp;pub=&amp;ssl=1&amp;sid=4d358407b896251f&amp;srd=1&amp;srf=0.02&amp;srp=0.2&amp;srx=0&amp;ver=250&amp;xck=0&amp;rev=88088&amp;xd=1"></iframe></div>
    <a name="top" id="top"></a>
    <div id="container">
      <a name="index" id="index"></a>
[…etc]

<h2>NEWS</h2>

所以我们可以看到新闻部分,所以我确实回到了主页。请注意,一些标记已通过脚本注入。您能否粘贴您正在使用的代码。

于 2011-01-18T12:22:02.307 回答
0

我们检查并发现在 Opera 的情况下,无论我们尝试使用什么文档或窗口属性,我们都没有获得对最顶层文档对象的引用。事实上,我们曾尝试使用 window.top 和 window.parent,但似乎没有提供窗口对象的句柄,并且这些属性返回 null。

关于这个“注入的脚本将被注入顶部文档以及页面上的任何 iframe”,我们仅从 iFrame 而不是从最顶部的窗口收到警报(我们包含在注入的脚本中)。我们发现您所说的内容仅在 Google Chrome 和 Safari 中是正确的。

于 2011-01-21T07:01:52.167 回答