GVKun编程网logo

如何更改iframe内容跨域样式?(如何更改iframe内容跨域样式的颜色)

19

在本文中,您将会了解到关于如何更改iframe内容跨域样式?的新资讯,同时我们还将为您解释如何更改iframe内容跨域样式的颜色的相关在本文中,我们将带你探索如何更改iframe内容跨域样式?的奥秘,

在本文中,您将会了解到关于如何更改iframe内容跨域样式?的新资讯,同时我们还将为您解释如何更改iframe内容跨域样式的颜色的相关在本文中,我们将带你探索如何更改iframe内容跨域样式?的奥秘,分析如何更改iframe内容跨域样式的颜色的特点,并给出一些关于css – 如何覆盖Iframe中的样式?、CSS覆盖iframe中的内容的主体样式?、flex 弹窗口嵌套iframe,移动窗体iframe内容不显示了问题处理、Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题的实用技巧。

本文目录一览:

如何更改iframe内容跨域样式?(如何更改iframe内容跨域样式的颜色)

如何更改iframe内容跨域样式?(如何更改iframe内容跨域样式的颜色)

我想将iframe中的内容的背景颜色设为黑色和将文本颜色设为白色,这是因为其默认设置为普通的白色背景和黑色文本。iframe
src属性指向我无法访问或无法在该域中放置任何文件或样式表的其他域。因此,考虑到这些条件,是否有可能仅在iframe内容中进行这些样式更改?

答案1

小编典典

唯一的可能性是通过您的代理加载iframe内容并修改HTML内容。您无法通过JavaScript从其他域访问iframe。

css – 如何覆盖Iframe中的样式?

css – 如何覆盖Iframe中的样式?

我正在使用来自 https://twitter.com/about/resources/followbutton的twitter follow us widget,我想改变文本的颜色.现在,文字是浅蓝色,在我的网站背景上效果不佳.

有没有办法覆盖iframe内的样式?如果是这样,怎么样?

解决方法

无法修改iframe中的内容的DOM或样式.你可以做的最好的事情是链接到一个不同风格的iframe,因为twitter提供了明暗主题.

编辑:话虽如此,< a>中有几个参数.可用于进一步自定义主题的标记.尝试根据自己的喜好修改数据按钮,数据文本颜色和数据链接颜色参数!

CSS覆盖iframe中的内容的主体样式?

CSS覆盖iframe中的内容的主体样式?

如何控制iframe中的body元素的背景图片和颜色?注意,嵌入的body元素有一个类,iframe是我的网站的一部分的页面。

我需要这个的原因是我的网站有一个黑色的背景分配给正文,然后一个白色背景分配给包含文本的div。 WYSIWYG编辑器在编辑时使用iframe嵌入内容,但它不包括div,因此文本很难阅读。

iframe的主体在编辑器中有一个没有在其他地方使用的类,所以Im假设这是放在那里,这样的问题可以解决。但是,当我将样式应用于class.body时,它们不会覆盖应用于body的样式。奇怪的是,样式确实出现在诅咒,所以ive不知道发生了什么!

谢谢

UPDATE – Ive尝试@ mikeq的解决方案添加一个样式到类的身体的类。这不会工作,当添加到主页样式表,但它添加了firebug工作。 Im假设这是因为firebug应用于页面上的所有所有ements,因为css不应用于iframe中。这是否意味着添加css后窗口加载与javascript将工作?

解决方法

iframe是您的网页中的一个“洞”,其中显示了另一个网页。 iframe的内容不是任何形状或形成您的父页面的一部分。

正如其他人所说,您的选择是:

>给在iframe中加载的文件必要的CSS>如果iframe中的文件来自与您的父域相同的域,那么您可以从父域中访问iframe中的文档的DOM。>不要使用iframe(你确定需要一个吗?)

flex 弹窗口嵌套iframe,移动窗体iframe内容不显示了问题处理

flex 弹窗口嵌套iframe,移动窗体iframe内容不显示了问题处理

一,弹框设置:

创建titlewindow组件内嵌套iframe,名称为UrlForm

<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"

...

close="PopUpManager.removePopUp(this);"

initialize="init()" 

 move="titlewindow1_moveHandler(event)">

<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
<fx:String id="url"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.core.Container;
import mx.events.MoveEvent;
import mx.managers.PopUpManager;
private function init():void
{
ifra.source =url;
}

//窗体移动时,iframe可以跟着移动。若不加此方法则无法移动iframe,因为iframe是div
protected function titlewindow1_moveHandler(event:MoveEvent):void
{
//标记组件,以便在稍后屏幕更新期间调用该组件的 updatedisplayList() 方法。
ifra.invalidatedisplayList();
}


]]>
</fx:Script>

<flexiframe:IFrame id="ifra" width="850" height="520" horizontalCenter="0" source="" />

</s:TitleWindow>

主窗体调用弹窗体:script代码

var urlF:UrlForm=new UrlForm();

urlF.url="http://www.baidu.com";
//下面的代码可以起到居中弹出的效果;
urlF.x=FlexGlobals.topLevelApplication.stage.stageWidth/2- urlF.width/2;  
urlF.y=FlexGlobals.topLevelApplication.stage.stageHeight/2- urlF.height/2;

PopUpManager.addPopUp(urlF,map,true);   
PopUpManager.centerPopUp(urlF); 

二,移动窗体iframe内容不显示了问题处理:

模板index.template.html 中的:

1,script脚本加入

params.wmode = "transparent";

如下:

 var params = {};
            params.quality = "high";
            params.bgcolor = "${bgcolor}";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.wmode = "transparent";

2,<noscript>中加入

<param name="wmode" value="transparent" />

如下:

<object ....

...

<param name="allowFullScreen" value="true" />
<param name="wmode" value="transparent" />

ok,完成


若是要修改iframe的背景色,则需要找到iframe源码中的IFrameExternalCalls.as中的:

"newDiv.style.backgroundColor = '#FFFFFF';" 
修改为要设置的颜色

Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题

Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题

原文地址: http://www.voidcn.com/article/p-kzlryzrd-bck.html

今天遇到一个很让人闹心的问题,就是我的Flex中为了嵌套一个jsp,所以在flex中嵌套一个包含JSP页面的Iframe。问题出现了,当我点击除了Iframe的其他地方的时候,Iframe中的内容全部消失了。刚开始我还困惑到底是怎么回事,后来才发现这个问题是完全可以解决的。解决的方法如下:

          在index.template.html中更改一个属性,index.template.html在你的flex工程下,目录为 :工程名\html-template\index.template.html。打开后,查看window的属性"wmode",看到后,将其值更改为"transparent"。一般一共会有三个地方。更改完后保存,重新编译,启动工程,成功!

         具体的代码如下:(注意红色字体)

<!-- saved from url=(0014)about:internet -->
<html lang="en">

<!--
Smart developers always View Source.

This application was built using Adobe Flex,an open source framework
for building rich Internet applications that get delivered via the
Flash Player or to desktops via Adobe AIR.

Learn more about Flex at http://flex.org
// -->

<head>
<Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!--  BEGIN browser History required section -->
<link rel="stylesheet" type="text/css" href="history/history.css" />
<!--  END browser History required section -->

<title>${title}</title>
<script src="AC_OETags.js" language="javascript"></script>

<!--  BEGIN browser History required section -->
<script src="history/history.js" language="javascript"></script>
<!--  END browser History required section -->

<style>
body { margin: 0px; overflow:hidden }
</style>
<script language="JavaScript" type="text/javascript">
<!--
// -----------------------------------------------------------------------------
// Globals
// Major version of Flash required
var requiredMajorVersion = ${version_major};
// Minor version of Flash required
var requiredMinorVersion = ${version_minor};
// Minor version of Flash required
var requiredRevision = ${version_revision};
// -----------------------------------------------------------------------------
// -->
</script>
<script src="../scripts/hello.js" language="javascript"></script>
</head>

<body scroll="no">
<script language="JavaScript" type="text/javascript">
<!--
// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
var hasProductInstall = DetectFlashVer(6,65);

// Version check based upon the values defined in globals
var hasRequestedVersion = DetectFlashVer(requiredMajorVersion,requiredMinorVersion,requiredRevision);

if ( hasProductInstall && !hasRequestedVersion ) {
 // DO NOT MODIFY THE FOLLOWING FOUR LInes
 // Location visited after installation is complete if installation is required
 var MMPlayerType = (isIE == true) ? "ActiveX" : "PlugIn";
 var MMredirectURL = window.location;
    document.title = document.title.slice(0,47) + " - Flash Player Installation";
    var MMdoctitle = document.title;

 AC_FL_runcontent(
  "src","playerProductInstall",
  "FlashVars","MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
  "width","${width}",
  "height","${height}",
  "align","middle",
  "id","${application}",
  "quality","high",
  "bgcolor","${bgcolor}",
  "name",
  "allowScriptAccess","sameDomain",
  "type","application/x-shockwave-flash",
  "wmode","transparent", 
  "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
} else if (hasRequestedVersion) {
 // if we've detected an acceptable version   transparent
 // embed the Flash Content SWF when all tests are passed
 AC_FL_runcontent(
   "src","${swf}",
   "width",
   "height",
   "align",
   "id",
   "quality",
   "bgcolor",
   "name",
   "allowScriptAccess",
   "type",
   "wmode", 
   "pluginspage","http://www.adobe.com/go/getflashplayer"
 );
  } else {  // flash is too old or we can't detect the plugin
    var alternateContent = 'Alternate HTML content should be placed here. '
   + 'This content requires the Adobe Flash Player. '
    + '<a href=http://www.adobe.com/go/getflash/>Get Flash</a>';
    document.write(alternateContent);  // insert non-flash content
  }
// -->
</script>
<noscript>
   <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
   id="${application}" width="${width}" height="${height}"
   codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
   <param name="movie" value="${swf}.swf" />
   <param name="quality" value="high" />
   <param name="bgcolor" value="${bgcolor}" />
   <param name="allowScriptAccess" value="sameDomain" />
   <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
    width="${width}" height="${height}" name="${application}" align="middle"
    play="true"
    loop="false"
    quality="high"
    allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash"
    pluginspage="http://www.adobe.com/go/getflashplayer" wmode="transparent">
   </embed>
 </object>
</noscript>
</body>
</html>

 

二、flex里嵌套iframe,点击iframe,再点击外层的组件,iframe里的html内容变没了,不知道为什么?

这个问题其实很简单... 里面加wmode="transparent"就OK了. 跟你代码没有关系. 其实就swf与网页容器的上下层关系问题.当你点击的时候,swf跑到容器后面去了.所以看不见.其实他在网页上的.
1、<object>里面加<param name="wmode" value="transparent" /><embed>加wmode="transparent"就OK了.
2、 flex4修改方式如下:也是修改目录名:工程名\html-template\index.template.html文件
 
具体代码如下:(注意红色字体)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!-- saved from url=(0014)about:internet -->
<html xmlns=" http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> 
    <!--
    Smart developers always View Source.
   
    This application was built using Adobe Flex,an open source framework
    for building rich Internet applications that get delivered via the
    Flash Player or to desktops via Adobe AIR.
   
    Learn more about Flex at http://flex.org
    // -->
    <head>
        <title>${title}</title>        
        <Meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <!-- Include CSS to eliminate any default margins/padding and set the height of the html element and
       the body element to 100%,because Firefox,or any Gecko based browser,interprets percentage as
    the percentage of the height of its parent container,which has to be set explicitly.  Initially,
    don't display flashContent div so it won't show if JavaScript disabled.
  -->
        <style type="text/css" media="screen">
   html,body { height:100%; }
   body { margin:0; padding:0; overflow:auto; text-align:center;
          background-color: ${bgcolor}; }  
   #flashContent { display:none; }
        </style>
  
  <!-- Enable browser History by replacing usebrowserHistory tokens with two hyphens -->
        <!-- BEGIN browser History required section ${usebrowserHistory}>
        <link rel="stylesheet" type="text/css" href="history/history.css" />
        <script type="text/javascript" src="history/history.js"></script>
        <!${usebrowserHistory} END browser History required section --> 
     
        <script type="text/javascript" src="swfobject.js"></script>
        <script type="text/javascript">
            <!-- For version detection,set to min. required Flash Player version,or 0 (or 0.0.0),for no version detection. -->
            var swfVersionStr = "${version_major}.${version_minor}.${version_revision}";
            <!-- To use express install,set to playerProductInstall.swf,otherwise the empty string. -->
            var xiSwfUrlStr = "${expressInstallSwf}";
            var flashvars = {};
            var params = {};
            params.quality = "high";
            params.bgcolor = "${bgcolor}";
            params.allowscriptaccess = "sameDomain";
            params.allowfullscreen = "true";
            params.wmode = "transparent";   //添加部分
            var attributes = {};
            attributes.id = "${application}";
            attributes.name = "${application}";
            attributes.align = "middle";
            swfobject.embedSWF(
                "${swf}.swf","flashContent",
                "${width}",
                swfVersionStr,xiSwfUrlStr,
                flashvars,params,attributes);
   <!-- JavaScript enabled so display the flashContent div in case it is not replaced with a swf object. -->
   swfobject.createCSS("#flashContent","display:block;text-align:left;");
        </script>
    </head>
    <body>
        <!-- SWFObject's dynamic embed method replaces this alternative HTML content with Flash content when enough
    JavaScript and Flash plug-in support is available. The div is initially hidden so that it doesn't show
    when JavaScript is disabled.
  -->
        <div id="flashContent">
         <p>
          To view this page ensure that Adobe Flash Player version
    ${version_major}.${version_minor}.${version_revision} or greater is installed.
   </p>
   <script type="text/javascript">
    var pageHost = ((document.location.protocol == "https:") ? "https://" : "http://");
    document.write("<a href='http://www.adobe.com/go/getflashplayer'><img src='"
        + pageHost + " www.adobe.com/images/shared/download_buttons/get_flash_player.gif' alt='Get Adobe Flash player' /></a>" );
   </script>
        </div>
     
        <noscript>
            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}" id="${application}">
                <param name="movie" value="${swf}.swf" />
                <param name="quality" value="high" />
                <param name="bgcolor" value="${bgcolor}" />
                <param name="allowScriptAccess" value="sameDomain" />
                <param name="allowFullScreen" value="true" />
                <param name="wmode" value="transparent" /><!--添加部分-->
                <!--[if !IE]>-->
                <object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
                    <param name="quality" value="high" />
                    <param name="bgcolor" value="${bgcolor}" />
                    <param name="allowScriptAccess" value="sameDomain" />
                    <param name="allowFullScreen" value="true" />
                <!--<![endif]-->
                <!--[if gte IE 6]>-->
                 <p>
                  Either scripts and active content are not permitted to run or Adobe Flash Player version
                  ${version_major}.${version_minor}.${version_revision} or greater is not installed.
                 </p>
                <!--<![endif]-->
                    <a href=" http://www.adobe.com/go/getflashplayer">
                        <img src=" http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash Player" />                     </a>                 <!--[if !IE]>-->                 </object>                 <!--<![endif]-->             </object>      </noscript>      </body> </html>

关于如何更改iframe内容跨域样式?如何更改iframe内容跨域样式的颜色的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于css – 如何覆盖Iframe中的样式?、CSS覆盖iframe中的内容的主体样式?、flex 弹窗口嵌套iframe,移动窗体iframe内容不显示了问题处理、Flex嵌套Iframe,点击除Iframe的其他地方后,Iframe内容消失的问题的相关知识,请在本站寻找。

本文标签: