Is it possible in javascript to generate the code of a new page, and then execute it in a new window? I understand no one has canceled the PHP language but still ...

I am writing a game script, it will not be a dimensional game field, it may be very large in width and would like this field and the game to open in a new window.

  • In the current form, it is impossible to give a concise answer to your question. To get an answer, explain exactly what you see the problem, what technologies you use and what you want to see in the answer. - Grundy
  • updated the answer .. - perfect
  • @perfect, even considering the fact that it can be done through JS, should not be done so - Dmitriy Simushev
  • @DmitriySimushev I have no other way out since the field does not fit into the site design - perfect
  • @perfect, there is always a way out. Well, the decision is all the same for you, I just pointed out the utmost kontilnost of your approach =) - Dmitriy Simushev

1 answer 1

Yes, it is quite real. JS can create (open) a new window and fill it with content. For example:

var newWin = window.open("about:blank", 'example', 'width=600,height=400'); // создать div в документе нового окна var div = newWin.document.createElement('div'), body = newWin.document.body; div.innerHTML = 'Добро пожаловать!' div.style.fontSize = '30px' // вставить первым элементом в body нового окна body.insertBefore(div, body.firstChild); 

The example is taken in part from here.