如何操纵iframe的内部html的CSS [英] how to manipulate css of inner html of iframe

查看:589
本文介绍了如何操纵iframe的内部html的CSS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个问题,我陷入了一个问题。问题是那样--->我必须操纵iframe的内部html的css,但是这个iframe的内容不是来自同一个域,所以怎么能它可以实现

直播例如 - 你可以采取(推文在我们的网站上提供,它来自另一个域名tweeter.com/bla....blaa但在我们的网页上呈现封装iframe ,那么我如何才能在我们的网站上设置推文部分)

i已经尝试过jQuery,但是它无法正常工作可以帮助我解决这个问题吗?

提前致谢: )

 <   head  >  
< script < span class =code-keyword>>
$( document )。ready(函数(){
$(' iframe')。contents()。find(' body')。 css(' background'' < span class =code-string> red');
$(' iframe')。contents()。find(' #div _')。css(' color'' green');});
< / script >
< / head >
< body >
< div class = < span class =code-keyword> carol height = width = 200px >
< iframe < span class =code-attribute> width = 500 heught = 300 src = iframe.html >
< html >
< head > < / head >
< body 样式 = 背景:#ffffff >
< div id = div _ style = color:red > helllo dud < / div >
< / body & gt;
< / html >
< / iframe >
< / div >
< / body >



这在我实施之后无效



$('iframe')。load(function(){

$('iframe')。contents()。find(head)

.append($(< style type ='text / css'> #div_ {color:green;}< / style>));

});

它也不起作用

解决方案

document )。ready( function (){


' iframe')。contents()。find(' body')。css(' background'' red');

' iframe')。contents()。find(' #div _')。css(' < span class =code-string> color',' green');} );
< / script >
< / head >
< body >
< div class = carol height = width = 200px >
< iframe width = 500 heught = 300 < span class =code-attribute> src = iframe.html >
< html < span class =code-keyword>>
< head > < / head >
< body style = 背景:#ffffff >
< div id = div _ style = color:red > helllo dud < / div >
< / body >
& / html >
< / iframe >
< / div >
< / body >



在我实施之后这不起作用



have one question, i trapped in a prob..The problem is like that --->I have to manipulate the css of inner html of iframe but the content of this iframe is not coming from same domain so how can it makes possible
live eg.-u can take ("tweets feed in our website ,it comes from another domain tweeter.com/bla....blaa but render on our web page encapsulate with iframe,so how can i style tweet section in our website")
i have tried by jQuery but its not working can u plz help me out in that ?
Thanks in advance :)

<head>
  <script>
$(document).ready(function() {
$('iframe').contents().find('body').css('background','red');
$('iframe').contents().find('#div_').css('color','green');});
  </script>
</head>
<body>
<div class="carol" height="" width="200px">
  <iframe width="500" heught="300" src="iframe.html">
        <html>
            <head></head>
            <body style="background:#ffffff">
                 <div id="div_" style="color:red">helllo dud</div>
            </body>
        </html>
  </iframe>
</div>
</body>


this is not working after that i have implement

$('iframe').load( function() {
$('iframe').contents().find("head")
.append($("<style type='text/css'> #div_{color:green;} </style>"));
});
it is also not working

解决方案

(document).ready(function() {


('iframe').contents().find('body').css('background','red');


('iframe').contents().find('#div_').css('color','green');}); </script> </head> <body> <div class="carol" height="" width="200px"> <iframe width="500" heught="300" src="iframe.html"> <html> <head></head> <body style="background:#ffffff"> <div id="div_" style="color:red">helllo dud</div> </body> </html> </iframe> </div> </body>


this is not working after that i have implement


这篇关于如何操纵iframe的内部html的CSS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆