Accessing a frame within a frame

后端 未结 4 1614
故里飘歌
故里飘歌 2021-01-22 07:30

Ok, here is the situation. I have a site that I subscribe to that lets you add your own code, etc. They have a forum editor that I am unable to skin to match my site, so I\'d li

4条回答
  •  花落未央
    2021-01-22 07:51

    Assuming your iframes are all on the same domain give this a shot:

    $(function() {
      $(window).load(function() {
        var iframe2body = $('iframe').contents().find('body');
        iframe2body.css({ 'background-color': '#333333', 'color': '#ffffd' }); // doc2 colors
        iframe2body.contents('iframe').contents().find('body').css({ 'background-color': '#fff', 'color': '#ffffd' }); // doc3 colors
       })
    })
    

    I didn't chain it ALL together purely for readability purposes and for IE I had to change it to $(window).load(function() {

提交回复
热议问题