0

我有 iframe 来表示下拉菜单。问题是当显示 iframe 时,我可以从父页面看到内容。

有没有办法不使 iframe 透明?

jQuery('<iframe id="accountframe" style="position: absolute; width: 290px; height:     140px;  margin-top: 0px;  margin-left: 0px; top:0px; left:0px; text-align:left overflow:hidden; allowTransparency:false"  src="test.jsp" ></iframe>').appendTo('#account');

我正在使用 jQuery 动态添加/删除 iframe。我已经尝试将 allowTransparency:false 作为样式表,也尝试将 allowTransparency="false" 作为属性,但是这两种方法都不起作用。

谢谢。

4

2 回答 2

2

how about allowTransparency="true" ? Since you do want it to be transparent?

It would also help to set background-color:transparent on the iframe, and to make sure that the page you load into the iframe does not define a background color in its body.

于 2013-11-12T13:15:47.217 回答
0

您的代码中有一些错误: allowTransparency不是 CSS 属性。allowtransparency是 iframe 元素上的一个属性。并且您将 allowTransparency 编写为 CSS 属性。

试试这个代码 -

jQuery('<iframe id="accountframe" style="position: absolute; width: 290px; height:140px; margin-top: 0px; margin-left: 0px; top:0px; left:0px; text-align:left overflow:hidden;" allowTransparency="false" src="test.jsp" ></iframe>').appendTo('#account');

有这篇文章

正如您所提到的,您也可以尝试allowTransparency="false"作为一个属性,但如果您想让您的IFrame透明。您需要allowTransparency="true"在 iframe 上进行设置。

确保 theIFRAME及其源BODY元素都应用了background:transparent样式规则:

<iframe frameborder="0" allowTransparency="true" style="background:transparent" ... ></iframe>

在源代码中:

<body style="background:transparent">

PS:上面的 CSS 样式是内联的,例如。

尝试这个:

jQuery('<iframe id="accountframe" style="position: absolute; width: 290px; height:140px; margin-top: 0px; margin-left: 0px; top:0px; left:0px; text-align:left overflow:hidden;" allowTransparency="true" src="test.jsp" ></iframe>').appendTo('#account');
于 2013-11-12T13:56:32.080 回答