如何使用javascript从IE中删除iframe边框
问题描述:
我试图通过javascript将iframe插入浏览器DOM,并希望删除边框,如果IE但似乎无法。我试过这些无济于事:
I am trying to insert an iframe into the browser DOM via javascript and want to remove the border if IE but can't seem to. I have tried these to no avail:
iframeElement.style.borderStyle="none";
和
iframeElement.style.frameBorder = "0";
我们非常感谢任何建议。
Any suggestions will be much appreciated.
答
奇怪的是,我今天早些时候正在寻找这个问题的答案。我发现将 frameBorder
设置为 0
属性确实有效,只要你在iframe之前执行已添加到文档中。
Bizarrely, I was looking for an answer to this very issue myself earlier today. I found that setting the frameBorder
to 0
property does work, so long as you do it before the iframe is added to the document.
var iframe = document.createElement("iframe");
iframe.frameBorder = 0;
document.body.appendChild(iframe);