React Js Open Link in New Window (not Tab)
React Js Open Link in New Window (not Tab):To open a link in a new window (not a new tab) in Reactjs, you can use the window.open
method within an event handler or a function. Provide the URL as the first parameter and "_blank" as the second parameter to specify opening a new window. This approach avoids the browser's tab grouping behavior, treating the link as a separate window, rather than a new tab in an existing window.




Thanks for your feedback!
Your contributions will help us to improve service.
How can I use ReactJS to open a link in a new window (not a new tab) when the user clicks on it?
This Reactjs example demonstrates how to open a link in a new window (not a new tab). When the "Open Link" button is clicked, the openLink
function is triggered. It uses window.open
to open the specified URL ("https://fontawesomeicons.com") in a new window with custom dimensions (width=500, height=500). The new window is given the "_blank" target to prevent it from opening in a new tab. If the window is successfully opened, it receives focus.
React Js Open Link in New Window (not Tab) Example
<script type="text/babel">
// Define the App component
const App = () => {
const openLink = () => {
const newWindow = window.open(
"https://fontawesomeicons.com",
"_blank",
"width=500,height=500"
);
if (newWindow) {
newWindow.focus();
}
};
return (
<div className="container">
<h3>React Js Open link in Window (not Tab)</h3>
<button onClick={openLink}>Open Link</button>
</div>
);
};
ReactDOM.render(<App />, document.getElementById("app"));
</script>