我正在尝试将 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 提要中的链接查看它。这已经完成了。
但是当博客页面在我的网站(与博客位于同一域中)的 iFrame 中呈现时,它的 CSS 需要设置为“background= transparent”。
有什么方法可以修改上面的 OK_loadit 脚本,以便在将页面加载到 iFrame 时相应地重置页面的背景参数,或者我是否需要完全使用不同的脚本?
不管怎样,如果有人能帮我找到我需要的东西,我将不胜感激。
谢谢!
詹姆斯
最佳答案
[编辑] 删除了之前的答案 [/编辑]
抱歉,我重新阅读了您的问题并意识到解决方案比我想象的要简单。
在您传递给此页面的 url 中,只需将 ?tran 添加到 url 字符串..
所以...
"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/