Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 为什么我的浏览器注释掉了iFrame中插入的样式_Jquery_Css - Fatal编程技术网

Jquery 为什么我的浏览器注释掉了iFrame中插入的样式

Jquery 为什么我的浏览器注释掉了iFrame中插入的样式,jquery,css,Jquery,Css,我将以下代码放入一个页面中,这样我就可以将样式添加到另一个加载到iframe中的页面中。但是当我用Firebug检查它时,浏览器正在注释我的javascript…有人能帮忙吗 $('#myframe').contents() .find("head") .append($("#iframe_id").contents() .find("head") .append(" <link rel='stylesheet' type='text/css' href

我将以下代码放入一个页面中,这样我就可以将样式添加到另一个加载到iframe中的页面中。但是当我用Firebug检查它时,浏览器正在注释我的javascript…有人能帮忙吗

$('#myframe').contents()
   .find("head")
   .append($("#iframe_id").contents()
     .find("head")
     .append("   <link rel='stylesheet' type='text/css' href='addStyles.css'/>")
   );
$('#myframe').contents()
.find(“head”)
.append($(“#iframe_id”).contents()
.find(“head”)
.附加(“”)
);

不允许编辑父文档中的
iframe
的内容,因为
iframe
的内容属于不同的URL

但是,您可以将JavaScript注入URL。请阅读以下内容:


希望有帮助。

好吧,我知道怎么做了。它不可能是跨域的(我还不知道)

但简单的做法是: $(#'myframe').contents().find('head').html(…某些样式…)


这对我来说很好。

好的。我来看看。iFrame中的src是来自域的,这就是为什么我认为它会工作的原因。是的,我知道你为什么会这么想。我还没有玩太多,让我知道你发现了什么。