HTML <a> target attribute provides an easy and simple way to open the linked URL in the new browser window or tab. You need to use the _blank value in the target attribute in the anchor tag to open the linked URL in a new tab or window.
<a href="https://www.codexworld.com" target="_blank">Visit CodexWorld</a>
If you want to open URL with JavaScript, the open() method of Window interface is the best option. The JavaScript window.open() method opens a new browser window. Use _blank
in the second parameter of window.open()
method to open a URL in a new tab using JavaScript.
The following JavaScript code will open https://www.codexworld.com
URL in a new browser tab or window.
window.open('https://www.codexworld.com', '_blank');
Great thanks!
where shall i put this. in the server.js or in another file?
because in the server.js isnt working… showing this in log:
ReferenceError: window is not defined
at Object. (c:\Users\javim\Desktop\ipgrabber\server.js:53:3)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
thank you for help me
How do i open it in the same tab?
And how can I open a page in the same tab? Thx for answering
Thanks, you helped us. That’s for our website. Y’all rock!
how to close the same after performing some actions in newly opened tab..? switch over to previous tab..
after opening new tab i need to know whether client has spent time in new tab or not.
Thank you! Really helped with this project that I was working on. Keep up the good work!