简体   繁体   中英

Append CSS to child pop-up window from parent

I'm trying to control the CSS properties of a pop-up window from the parent page, without wiping its content. As a link is clicked, a pop-up appears with a certain fixed content and style that are already present. So here's what I'm doing:

<script type="text/javascript">
    function popupcontrol(url) {
        control = window.open(url, 'RT', 'width=800,height=600,screenX=100,screenY=100,toolbar=0,resizable=0,scrollbars=1');
    ...
    }
</script>

I would like to append something like this:

$("head").append("<link rel='stylesheet' href='/css/newCss.css' type='text/css'>");

but how am I supposed to select the head of the pop-up page which is assigned to the above specified variable control ?

You need to use the returned window reference and then find subchildren of that.

$(control.document).find('head').append(
    "<link rel='stylesheet' href='/css/newCss.css' type='text/css'>"
);

relevant answer

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