Modifying the DOM in a new window

Modifying the DOM in a new window

So I'm opening a new window with the following code:

  1.     scoreboardWindow = window.open("scoreboard.html","scoreboard");
  2.     
  3.     $("head *", scoreboardWindow.document).remove()
  4.     $("head", scoreboardWindow.document).append("<style>\n" +
  5.         "table {\n" +
  6.         "    font-size: 40px;\n" +
  7.         "    font-family: Candara, Verdana, Arial, sans;\n" +
  8.         "    margin-left: auto;\n" +
  9.         "    margin-right: auto;\n" +
  10.         "}\n" +

  11.         "tr td:first-child {font-weight: bold;}\n" +

  12.         "tr:nth-child(odd) td:first-child {background-color: #ccc;}\n" +
  13.         "tr:nth-child(even) td:first-child {background-color: #aaa;}\n" +

  14.         "tr:nth-child(odd) td:nth-child(2) {background-color: #f88;}\n" +
  15.         "tr:nth-child(even) td:nth-child(2) {background-color: #f44;}\n" +

  16.         "tr:nth-child(odd) td:nth-child(3) {background-color: #88f;}\n" +
  17.         "tr:nth-child(even) td:nth-child(3) {background-color: #44f;}\n" +

  18.         "td, th, table {\n" +
  19.         "    padding: 5px;\n" +
  20.         "    border: 1px solid #000;\n" +
  21.         "    border-collapse: collapse;\n" +
  22.         "}\n" +

  23.         "body { width: 100%;}\n" +
  24.     "</style>");
Originally I had the new window open blank and added all the markup programatically, but I thought I might try having it in an external file for easier maintenance. The problem is it isn't replacing the markup in the new window. That won't be a problem for this particular piece of code since I plan to remove it anyway and put it in the external file, but when I get around to modifying parts of the DOM I need to modify I will not be able to.

So, in a nutshell, if I open the window without a url, I have no problems modifying the DOM as I need, but if I open it with a url I can't modify the DOM. My testing has shown my that scoreboardWindow.document is undefined when a url is supplied, but I'm not sure why, and my google searches are not returning any useful results.

In case you need a little more information, my goal is to have this be a controller for a scoreboard window that will be fullscreened and projected using a second monitor, and I only need to support Chrome, so if there are any Chrome specific tricks, I'm all for it.