Question

I'm developing a BHO to deny access in prohibited websites. So when I find a certain URL, I just open an iframe with the code below:

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. How to overlap the entire website with the content of my iframe?

Était-ce utile?

La solution

Set the position to absolute.

Autres conseils

If you want absolutely block - you should not ADD element, you should REPLACE it.

So you have to make full-blown HTML page. Then you probably can redirect browser to it, changing Document.Location property. Or replace older content with new one doing Document.OuterHTML := .... your string.

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 ? I'd better ban prohiobited sites via \windows\system32\drivers\etc\hosts or via group policies. Much more reliable.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top