I would not recomend you to use document.write as others suggest, because if you will open such window twice your HTML will be duplicated 2 times (or more).

Use innerHTML instead

var win = window.open("", "Title", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=780,height=200,top="+(screen.height-400)+",left="+(screen.width-840));
win.document.body.innerHTML = "HTML";
Answer from artnikpro on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
The open() method of the Window interface loads a specified resource into a new or existing browsing context (that is, a tab, a window, or an iframe) under a specified name. ... A string indicating the URL or path of the resource to be loaded. If an empty string ("") is specified or this parameter ...
🌐
Gitbooks
makersinstitute.gitbooks.io › html-css-js › content › fifth-chapter › the-windowopen-method.html
The Window.open() Method · HTML + CSS + JS
Then I open the window with this ... inside the parentheses to specify how you want the window to open. The 3 parameters are: A URL so that the window contains a specific HTML document....
🌐
Jennifermadden
jennifermadden.com › javascript › window3.html
Writing Dynamic Content to a New Window
function popUp(){ var frog = window.open("","wildebeast","width=300,height=300,scrollbars=1,resizable=1") var text = document.form.input.value var html = "<html><head></head><body>Hello, <b>"+ text +"</b>." html += "How are you today?</body></html>" //variable name of window must be included for all three of the following methods so that //javascript knows not to write the string to this window, but instead to the new window frog.document.open() frog.document.write(html) frog.document.close() } Although we cannot create a new HTML document with JavaScript, we can overwrite the contents of an existing document.
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
The open() method opens a new browser window, or a new tab, depending on your browser settings and the parameter values.
🌐
Quora
quora.com › How-would-I-code-an-automatic-new-window-opening-in-HTML
How would I code an automatic new window opening in HTML? - Quora
Answer (1 of 2): [code] Click below button For New window Click function myFunction() { window.open("http://jaydipvaghasiya.comli.com/", "_blank", "toolbar=yes,scrollbars=yes,resiz...
🌐
DevGenius
blog.devgenius.io › creating-a-pop-up-window-in-html-with-custom-html-content-using-javascript-7a7bdf1a0394
Creating a Pop-up Window in HTML with Custom HTML Content using JavaScript | by Popa Vlad | Dev Genius
March 6, 2025 - <a href="#" target="_blank" onclick="event.preventDefault(); window.open('about:blank').document.write('This is the content of the link.');">Click me</a> ... Vlad is an IT enthusiast with experience in multiple areas of Technology.
Find elsewhere
🌐
JavaScript.info
javascript.info › tutorial › frames and windows
Popups and window methods
The syntax to open a popup is: window.open(url, name, params): ... An URL to load into the new window. ... A name of the new window. Each window has a window.name, and here we can specify which window to use for the popup.
🌐
javaspring
javaspring.net › blog › open-window-in-javascript-with-html-inserted
How to Open a New Window in JavaScript and Insert HTML Data (Without Linking to an External File) — javaspring.net
In this guide, we’ll explore how to use JavaScript’s window.open() method to create a new browser window and dynamically inject HTML (and CSS!) directly into it—no external files required.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-window-open-method
JavaScript window.open() Method - GeeksforGeeks
August 5, 2025 - ... <!DOCTYPE html> <head> <style> body { background-color: #272727; display: flex; justify-content: center; align-items: center; margin-top: 20%; } .main { width: 50%; height: 100%; display: ...
🌐
TutorialsPoint
tutorialspoint.com › how-to-open-link-in-a-new-window-javascript
How to open link in a new window using JavaScript?
<!DOCTYPE html> <html> <body ... displays the anchor link on the webpage. If the user clicks the link, the event gets triggered and opens the content in the new window....
🌐
Javatpoint
javatpoint.com › javascript-window-open-method
JavaScript Window open method - javatpoint
JavaScript Window open method with javascript tutorial, introduction, javascript oops, application of javascript, loop, variable, objects, map, typedarray etc.
🌐
P2hp
w3.p2hp.com › js › tryit.asp
Open a new window, and add some content - W3Schools
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
SitePoint
sitepoint.com › javascript
JS to open window
February 22, 2018 - This is the code that I currently use to open a window for a click here for explanation. <div class=body><a id="terms" name="explain" style="font-size:12px;color:blue;text-decoration:underline; cursor:pointer;" onclick=…