我正在尝试将CSS应用于要加载到iFrame中的文档。我正在使用OK_loadit函数,如下所示:
function OK_loadit(url,layerObjNS, width) {
if (document.layers){
document.layers[layerObjNS].load(url, width);
} else{
if (window.frames.length > -1){
window.frames[layerObjNS].location.href = url;
}
我正在加载到iFrame中的文档是一个php Seresnipity博客页面。
博客页面的CSS需要设置为“ background =#000000”,以便可以从具有黑色背景的RSS feed中的链接进行查看。已经完成了。
但是,当博客页面在其网站上的iFrame(与博客位于同一域)中呈现时,则需要将CSS设置为“背景=透明”。
有什么方法可以修改上面的OK_loadit脚本,以便在将页面的背景参数加载到iFrame时可以相应地重置它的背景参数,还是我需要完全使用其他脚本?
无论哪种方式,如果这里有人可以让我满足我的需求,我将非常感激。
谢谢!
詹姆士
最佳答案
[编辑]
删除以前的答案
[/编辑]
抱歉,我重新阅读了您的问题,并意识到该解决方案比我想象的要容易。
在您要传递到此页面的url中,只需在URL字符串中添加?tran。
所以...
“ myPage.php?tran”
然后在php页面中添加此...
<script>
document.onload = function(){
if(self.location.query.indexOf("?tran") == 0)
document.bgColor = "transparent"
}
</script>
我认为应该可以。
关于javascript - 如何使用OK_loadit函数将CSS应用于iFrame?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8046668/