1

我正在开发一个 BHO 来拒绝访问被禁止的网站。因此,当我找到某个 URL 时,我只需使用以下代码打开一个 iframe:

Document:= IE.Document as IHTMLDocument2;
iFrame:= Document.createElement('iframe');
iFrame.setAttribute('src', 'denied.html', 0);
iFrame.setAttribute('position', 'fixed', 0);
iFrame.style.width:= '100%';
iFrame.style.left:= '0px';
iFrame.style.top:= '0px';
iFrame.style.border:= '0px';
iFrame.style.height:= '100%';
(Document.body as IHTMLDomNode).appendChild(iFrame as IHTMLDomNode);

但是这段代码只是将 iframe 打开到网站末尾的一个小空间中。如何将整个网站与我的 iframe 内容重叠?

4

2 回答 2

3

将位置设置为绝对

于 2012-08-16T14:55:01.177 回答
3

如果你想要绝对阻塞 - 你不应该添加元素,你应该替换它。

所以你必须制作成熟的 HTML 页面。然后您可能可以将浏览器重定向到它,更改 Document.Location 属性。或者用新的内容替换旧的内容 Document.OuterHTML := .... 你的字符串。

经验法则很简单 - 不是通过替换附加,一种或另一种方式。

PS:为什么可以在浏览器选项中轻松禁用仅 IE 的 BHO?我最好通过 \windows\system32\drivers\etc\hosts 或通过组策略禁止禁止站点。可靠得多。

于 2012-08-16T14:56:41.747 回答