简体   繁体   中英

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.

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

 <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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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