Javascript Window Open() & Window Close() Method Last Updated : 01 Aug, 2024 Comments Improve Suggest changes Like Article Like Report The Javascript Window.Open() method is used to open the web pages into a new window or a new tab. It depends on the browser settings and the values assigned to the parameter. Syntax:window.open(URL, name, specs, replace)Parameters: This method accepts four parameters as mentioned above and described below:URL: It is an optional parameter. It is used to set the URL of web pages that need to open. If the URL is not set then window.open() method opens a blank window.name: It is an optional parameter and is used to set the window name.specs: It is an optional parameter used to separate the item using a comma.replace: It is an optional parameter and used to specify the URL URL creates a new entry or replaces the current entry in the history list. This parameter returns a boolean value. If this parameter returns true then URL replaces the current document in the history list and if returns false then URL creates a new entry in the history list.Return Value: This method creates a new window. Window.close(): This method is used to close the window which is opened by the window.open() method. Syntax:window.close()Parameters: This method does not contain any parameters. Return Value: This method does not return any value. Example: The below example illustrates the window.open() and window.close() method in Javascript. If you click on the Open GeeksforGeeks button then the geeksforgeeks.org page opens in a new window and if you click on the close GeeksforGeeks button then the geeksforgeeks.org windows will close. HTML <!DOCTYPE html> <html> <head> <title>window open and close method</title> </head> <body style="display: flex; flex-direction: column; justify-content:center; align-items:center;"> <div class="container" style="position: relative; text-align: center;"> <h1 style="color: rgb(18, 154, 18);"> GeeksforGeeks </h1> <h3> window open and close method</h3> <button onclick="windowOpen()"> Open GeeksforGeeks </button> <button onclick="windowClose()"> Close GeeksforGeeks </button> </div> <script> let Window; // Function that open the new Window function windowOpen() { Window = window.open( "https://www.geeksforgeeks.org/", "_blank", "width=400, height=300, top=230, left=540"); } // function that Closes the open Window function windowClose() { Window.close(); } </script> </body> </html> Output: Supported Browser: The browsers are supported by the window.open() & window.close() method are listed below:Chrome version 1 and aboveEdge version 12 and aboveFirefox version 1 and aboveInternet Explorer version 4 and aboveOpera version 3 and aboveSafari version 1 and aboveJavaScript is best known for web page development but it is also used in a variety of non-browser environments. You can learn JavaScript from the ground up by following this JavaScript Tutorial and JavaScript Examples.HTML is the foundation of web pages and is used for webpage development by structuring websites and web apps. You can learn HTML from the ground up by following this HTML Tutorial and HTML Examples. Comment More infoAdvertise with us Next Article Javascript Window Open() & Window Close() Method N Naman_Garg Follow Improve Article Tags : JavaScript Web Technologies JavaScript-Methods Similar Reads JavaScript Tutorial JavaScript is a programming language used to create dynamic content for websites. It is a lightweight, cross-platform, and single-threaded programming language. It's an interpreted language that executes code line by line, providing more flexibility.JavaScript on Client Side: On the client side, Jav 11 min read Web Development Web development is the process of creating, building, and maintaining websites and web applications. It involves everything from web design to programming and database management. Web development is generally divided into three core areas: Frontend Development, Backend Development, and Full Stack De 5 min read React Interview Questions and Answers React is an efficient, flexible, and open-source JavaScript library that allows developers to create simple, fast, and scalable web applications. Jordan Walke, a software engineer who was working for Facebook, created React. Developers with a JavaScript background can easily develop web applications 15+ min read JavaScript Interview Questions and Answers JavaScript (JS) is the most popular lightweight, scripting, and interpreted programming language. JavaScript is well-known as a scripting language for web pages, mobile apps, web servers, and many other platforms. Both front-end and back-end developers need to have a strong command of JavaScript, as 15+ min read React Tutorial React is a JavaScript Library known for front-end development (or user interface). It is popular due to its component-based architecture, Single Page Applications (SPAs), and Virtual DOM for building web applications that are fast, efficient, and scalable.Applications are built using reusable compon 8 min read Domain Name System (DNS) DNS is a hierarchical and distributed naming system that translates domain names into IP addresses. When you type a domain name like www.geeksforgeeks.org into your browser, DNS ensures that the request reaches the correct server by resolving the domain to its corresponding IP address.Without DNS, w 8 min read NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net 15+ min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read What is an API (Application Programming Interface) In the tech world, APIs (Application Programming Interfaces) are crucial. If you're interested in becoming a web developer or want to understand how websites work, you'll need to familiarize yourself with APIs. Let's break down the concept of an API in simple terms.What is an API?An API is a set of 10 min read Introduction of Firewall in Computer Network A firewall is a network security device either hardware or software-based which monitors all incoming and outgoing traffic and based on a defined set of security rules it accepts, rejects, or drops that specific traffic. It acts like a security guard that helps keep your digital world safe from unwa 10 min read Like