简体   繁体   English

如何使用跨域jquery在跨域iframe中更改css,这意味着外部链接

[英]How to change css in cross-domain iframe using jquery for cross-domain means external link

How i implement css in iframe my url is from cross-domain please help me how to do that. 我如何在iframe中实现css,我的网址来自跨域,请帮助我该怎么做。

Please check my code:- 请检查我的代码:-

<iframe allowtransparency="true" frameborder="0" height="1200" 
  id="cpatsframe" scrolling="no" src="https://Ghost.Org/jobs? 
       aggregator_id=180015&amp;embed=1" style="position: relative; 
    overflow: hidden; height: 2909px;" width="100%">Sorry, iframes are not 
  supported.</iframe>


   <script>

    $("#myframe").contents().find(".myclass").css('background', 'red');


    </script>

But this is not working Please tell me how i fix that or work it. 但这不起作用,请告诉我如何解决或起作用。 Thanks alot In advance 非常感谢

Try this if iframe is in same domain 如果iframe在同一个域中,请尝试此操作

 <script>
    $(document).ready(function(){
        var iFrameDOM = $("iframe#cpatsframe").contents();
        iFrameDOM.find(".myclass").css("background-color", "red");
    });
</script>

else There is no way to edit a Cross Domain IFrame. else无法编辑跨域IFrame。 You can manipulate domains within the same level, or lower in your domain chain but there is no way to made changes in cross domain iframe. 您可以在同一级别内或在您的域链的下层操作域,但是无法在跨域iframe中进行更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM