如何将CSS应用于iframe? |
您所在的位置:网站首页 › css样式应用于 › 如何将CSS应用于iframe? |
我有一个简单的页面,其中包含一些iframe部分(以显示RSS链接)。 如何将相同的CSS格式从首页应用到iframe中显示的页面? #1楼上面有一些更改的作品: var cssLink = document.createElement("link") cssLink.href = "pFstylesEditor.css"; cssLink.rel = "stylesheet"; cssLink.type = "text/css"; //Instead of this //frames['frame1'].document.body.appendChild(cssLink); //Do this var doc=document.getElementById("edit").contentWindow.document; //If you are doing any dynamic writing do that first doc.open(); doc.write(myData); doc.close(); //Then append child doc.body.appendChild(cssLink);至少与ff3和ie8兼容 #2楼我在Google日历中遇到了这个问题。 我想在深色背景上设置样式并更改字体。 幸运的是,嵌入代码中的URL对直接访问没有任何限制,因此通过使用PHP函数file_get_contents可以从页面中获取全部内容。 除了调用Google URL之外,还可以调用服务器上的php文件,例如。 google.php ,其中将包含原始内容并进行了修改: $content = file_get_contents('https://www.google.com/calendar/embed?src=%23contacts%40group.v.calendar.google.com&ctz=America/Montreal');将路径添加到样式表: $content = str_replace('','', $content);(这会将您的样式表放在head标记之前的最后。) 在相对调用js和js的情况下,从原始URL指定基本URL: $content = str_replace('','', $content);最终的google.php文件应如下所示: |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |