Using CSS to affect div style inside iframe

前端 未结 13 1547
失恋的感觉
失恋的感觉 2020-11-22 07:00

Is it possible to change styles of a div that resides inside an iframe on the page using CSS only?

13条回答
  •  抹茶落季
    2020-11-22 07:22

    Use Jquery and wait till the source is loaded, This is how I have achieved(Used angular interval, you can use javascript setInterval method):

    var addCssToIframe = function() {
        if ($('#myIframe').contents().find("head") != undefined) {
            $('#myIframe')
                    .contents()
                    .find("head")
                    .append(
                            '');
            $interval.cancel(addCssInterval);
        }
    };
    var addCssInterval = $interval(addCssToIframe, 500, 0, false);
    

提交回复
热议问题