Definitely the second method is preferred because you don't have the overhead of another function invocation:

window.location.href = "webpage.htm";
Answer from Jacob Relkin on Stack Overflow
🌐
W3Schools
w3schools.com › jsref › met_win_open.asp
Window open() Method
var myWindow = window.open("", "_self"); myWindow.document.write("<p>I replaced the current window.</p>"); Try it Yourself » · Open a new window and control its appearance: window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"); Try it Yourself » ·
🌐
W3Schools
www-db.deis.unibo.it › courses › TW › DOCS › w3schools › jsref › met_win_open.asp.html
Window open() Method - w3schools
var myWindow = window.open("", "_self"); myWindow.document.write("<p>I replaced the current window.</p>"); Try it Yourself » · Open a new window and control its appearance: window.open("http://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"); Try it Yourself » ·
🌐
W3Schools
w3schools.com › jsref › prop_win_opener.asp
Window opener Property
const myWindow = window.open("", "", "width=300,height=300"); myWindow.opener.document.getElementById("demo").innerHTML = "HELLO!"; Try it Yourself »
🌐
W3Schools
w3schools.com › jsref › prop_win_self.asp
Window self Property
addeventlistener() alert() atob() blur() btoa() clearInterval() clearTimeout() close() closed confirm() console defaultStatus document focus() frameElement frames history getComputedStyle() innerHeight innerWidth length localStorage location matchMedia() moveBy() moveTo() name navigator open() opener outerHeight outerWidth pageXOffset pageYOffset parent print() prompt() removeEventlistener() resizeBy() resizeTo() screen screenLeft screenTop screenX screenY scrollBy() scrollTo() scrollX scrollY sessionStorage self setInterval() setTimeout() status stop() top Window Console
🌐
P2hp
w3.p2hp.com › jsref › met_win_open.asp
Window open() Method - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › API › Window › open
Window: open() method - Web APIs | MDN
If this feature is set, the new window will not have access to the originating window via Window.opener and returns null. When noopener is used, non-empty target names, other than _top, _self, and _parent, are treated like _blank in terms of deciding whether to open a new browsing context.
🌐
W3Schools
w3schools.am › jsref › met_win_open.html
Window open() Method - W3Schools
var myWindow = window.open("", "_self"); myWindow.document.write("<p>I replaced the current window.</p>"); Try it Yourself » · Open a new window and control its appearance: window.open("https://www.w3schools.com", "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=400,height=400"); Try it Yourself » ·
🌐
W3Schools
w3schools.com › jsref › tryit.asp
W3Schools Tryit Editor - The Window Object
The W3Schools online code editor allows you to edit code and view the result in your browser
Find elsewhere
🌐
W3Schools
w3schools.com › js › tryit.asp
Open a new window and control its appearance
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
W3Schools
w3schools.invisionzone.com › browser scripting › javascript
Self timed window opener - JavaScript - W3Schools Forum
March 24, 2007 - I do not want to open a new window with a link, a button, or some other event, that is readily available. nor do I want to close a window with a timer.I want to wait say 5 seconds and have a script open a new window with a predefined size and so forth, I got the predefined size and window locatio...
🌐
GitHub
gist.github.com › sttk › 22e74eaadde493265f38c539f3cafb37
Window open · GitHub
If this value is "_parent", opens no new window and: If the window has a parent window, reload its parent window · If the window does not have its parent window (window.self === window.parent), make th window itself target.
🌐
W3Schools
w3schoolsua.github.io › js › js_window_en.html
JavaScript Window - The Browser Object Model. Lessons for beginners. W3Schools in English
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, Python, PHP, Bootstrap, Java, XML and more.
🌐
W3Schools
w3schools.com › js › tryit.asp
W3Schools online HTML editor
The W3Schools online code editor allows you to edit code and view the result in your browser
🌐
W3Schools
w3schools.com › jsref › met_doc_open.asp
HTML DOM Document open() Method
const myWindow = window.open(); myWindow.document.open(); myWindow.document.write("<h1>Hello World!</h1>"); myWindow.document.close(); Try it Yourself »
🌐
GeeksforGeeks
geeksforgeeks.org › javascript › javascript-window-open-method
JavaScript window.open() Method - GeeksforGeeks
August 5, 2025 - URL: It accepts the URL that will be open in the new window. If an empty string is provided then it will open a blank new tab. windowName: It can be used to provide the name of the window. This is not associated with the title of the window in any manner. It can accept values like _blank, _self, _parent, etc.
🌐
Experts Exchange
experts-exchange.com › questions › 21796916 › Open-a-new-window-with-self-location-href.html
Solved: Open a new window with self.location.href?? | Experts Exchange
March 31, 2006 - I know self opens in the same window. Thanks! Zero AI Policy · We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads. bubbledragon · window.open() ?? bubbledragon · http://www.w3schools.com/htmldom/met_win_open.asp ·
🌐
W3Schools
w3schools.com › jsref › met_win_close.asp
Window close() Method
function openWin() { myWindow = window.open("https://www.w3schools.com", "_blank", "width=200, height=100"); } function closeWin() { myWindow.close(); } Try it Yourself »