简体   繁体   English

与iframe重叠的网站

[英]Overlap website with iframe

I'm developing a BHO to deny access in prohibited websites. 我正在开发BHO,以禁止访问禁止访问的网站。 So when I find a certain URL, I just open an iframe with the code below: 因此,当我找到某个网址时,我只需使用以下代码打开一个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);

but this code just opens the iframe into a little space at the end of the website. 但是这段代码只是在网站末尾的空白处打开了iframe。 How to overlap the entire website with the content of my iframe? 如何将整个网站与iframe的内容重叠?

将位置设置为absolute

If you want absolutely block - you should not ADD element, you should REPLACE it. 如果要绝对阻止-不应添加元素,则应替换它。

So you have to make full-blown HTML page. 因此,您必须制作完整的HTML页面。 Then you probably can redirect browser to it, changing Document.Location property. 然后,您可能可以将浏览器重定向到它,更改Document.Location属性。 Or replace older content with new one doing Document.OuterHTML := .... your string. 或用做Document.OuterHTML:= ....的新内容替换旧内容。

The rule of thumb is simple - not append by replace, one way or another. 经验法则很简单-不能以一种或另一种方式通过替换附加。

PS: why IE-only BHO that can easily be disabled in browser options ? PS:为什么可以在浏览器选项中轻松禁用仅IE的BHO? I'd better ban prohiobited sites via \\windows\\system32\\drivers\\etc\\hosts or via group policies. 我最好通过\\ windows \\ system32 \\ drivers \\ etc \\ hosts或通过组策略来禁止prohiobited网站。 Much more reliable. 更可靠。

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

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