为什么身高不是100%

Why height is not 100%?

本文关键字:100% 高不 为什么      更新时间:2023-09-26

我正在开发一个BHO来拒绝访问禁止的URL。因此,当我找到一些目标 URL 时,我只需取消导航并打开一个 iframe 到另一个被拒绝的 .html。但是由于某种原因,这个 iframe 的高度不是 100%。它出现在页面的 20% 左右。创建 iframe 的代码是:

  if pos('live.com', URL) > 0 then
    begin
      Cancel:= true;
      Document:= IE.Document as IHTMLDocument2;
      Document.body.innerHTML:= '';
      Document.body.style.height:= '100%';
      iFrame:= Document.createElement('iframe');
      iFrame.setAttribute('src', 'denied.html', 0);
      iFrame.setAttribute('position', 'absolute', 0);
      iFrame.style.height:= '100%';
      iFrame.style.width:= '100%';
      iFrame.style.left:= '0px';
      iFrame.style.top:= '0px';
      iFrame.style.border:= '0px';
      (Document.body as IHTMLDomNode).appendChild(iFrame as IHTMLDomNode);
    end;

我正在使用 live.com 进行测试。 和行:

Document.body.style.height:= '100%';

是因为我已经在互联网上读到这个问题可能是因为 html 没有达到 100% 的高度,所以我做了测试,但仍然不起作用。有人为我提供解决方案??

将 html 和正文都设置为 100%

html, body { height : 100% }