- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What's the best way to open new browser window using JavaScript?
The open() method of window object is the best way to open new browser window using JavaScript
Following is the code for opening new browser window using JavaScript −
Example
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Document</title> <style> body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } </style> </head> <body> <h1>Open new browser window using JavaScript</h1> <br /> <button class="Btn">CLICK HERE</button> <h3>Click on the above button open a new browser window</h3> <script> let BtnEle = document.querySelector(".Btn"); BtnEle.addEventListener("click", (event) => { window.open("https://www.google.com"); }); </script> </body> </html>
Output
On clicking the ‘CLICK HERE’ button, it will redirect to the specified website −
- Related Articles
- What's the best way to detect a 'touch screen' device using JavaScript?
- How to open a new window on a browser using Selenium WebDriver for python?
- What's the best way to ensure a happy marriage?
- What's the best way to trim std::string in C++?
- How to open link in a new window - JavaScript?
- How to open a website in Android's web browser from my application using Kotlin?
- Open New Browser Tab in Selenuim
- How to open browser window in incognito/private mode using python selenium webdriver?
- How to open a website in iOS's web browser from my application?
- How to disable browser's back button with JavaScript?
- How to open a browser window in full screen using Selenium WebDriver with C#?
- What is the best way to handle a Javascript popup using Selenium Webdriver?
- How to open a link in new tab of chrome browser using Selenium WebDriver?
- How to open new tab in same browser and switch between them using Selenium?
- What's the simplest way to print a Java array?

Advertisements