简体   繁体   中英

ReactJS - opening url in new tab not working properly

I want to open url in new tab. I used window.open("url", "_blank").focus() . I have url for example "localhost:3000/index" and I open url "www.page.com" and it opens new tab with url "localhost:3000/www.page.com". But I want just "www.page.com". In my project I also use BrowserRouter from react-router-dom. Is it the reason why it is not working?

Thanks for any answer

You should use https:// at the beginning of the url if you are directing to a page out of the application.

window.open("https://www.page.com","_blank");

source

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM