gpt4 book ai didi

html - 如何在不损害 HTML 有效性的情况下消除 FRAME 之间的间隙?

转载 作者:太空宇宙 更新时间:2023-11-04 15:42:23 25 4
gpt4 key购买 nike

我知道框架不好。但是我必须再坚持一段时间。我的问题来自“frameset”元素的非标准“border”属性:

<frameset border="0">
...
</frameset>

如果我不使用该属性,浏览器会在每一帧之间放置一个间隙。如果我使用该属性,HTML 验证器会抛出关于“不支持的属性”的错误。

现在我听到你说“使用它并忽略验证器”,没关系。我想我可以接受一个验证器警告,浏览器似乎也不太担心它 :)

我的问题主要是关于 HTML 欺骗。如何将边框设置为 0 并保持浏览器兼容?将此视为 future 类似问题的练习。例如我试过:

<frameset onload="this.border='0'">

但它没有用。

我尝试在内部框架中使用样式表来设置“border:0;margin:0;padding:0”,它也没有用。 Gap 似乎来自不明来源。

我想用 Javascript 编写如下:

document.write('<frameset border="0">');

但我有预感无论如何它都无法验证。

你能想到替代解决方案吗?


其他无效的解决方案:

  • @Donut:“frame”或“frameset”元素上的“frameborder”属性
  • @kangax: frameSetObj.setAttribute('border', 0);

最佳答案

根据我的测试,这些应该有效:

歌剧 (10):

frameSetObj.setAttribute("framespacing", "0");

对于 IE8:

frameSetObj.setAttribute("framespacing", "0");
//set rows and cols attributes again if the frameset already had them.
frameSetObj.setAttribute("rows", rows);
frameSetObj.setAttribute("cols", cols);

对于 FireFox 3.5 和 Chrome 3

frameSetObj.setAttribute("frameborder", "0");
//same idea as IE8
frameSetObj.setAttribute("rows", rows);
frameSetObj.setAttribute("cols", cols);

总而言之,这段代码应该适用于所有浏览器:

frameSetObj.setAttribute("framespacing", "0");
frameSetObj.setAttribute("frameborder", "0");
frameSetObj.setAttribute("rows", rows);
frameSetObj.setAttribute("cols", cols);

关于html - 如何在不损害 HTML 有效性的情况下消除 FRAME 之间的间隙?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1428817/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com