2

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?

Gmart
  • 43
  • 6

1 Answers1

1

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

Community
  • 1
  • 1
actual_kangaroo
  • 5,971
  • 2
  • 31
  • 45
  • Looking at the syntax, this is exactly what I was looking for. The problem is, it doesn't seem to work. I cannot find that new line added to the source HTML of the popup page. I am starting to wonder whether there are any restrictions as regards the permissions to write on that page. The odd thing is that, if I simply want to write something on that page via `document.write(...)`, the content on that page is actually wiped and replaced. – Gmart Dec 06 '13 at 15:31