简体   繁体   中英

How to open a new tab from a react front-end app

Okay so what I am trying to do is create a twitter front-end application that allows users to post tweets. The problem I'm having is during the 3-legged Auth sequence, I get a response from the twitter api in form of a html and I need to open that response data in a new window so the user can accept whatever it is and allow my app to access their account. Could someone point me in the right direction. I don't want to get into building a backend to do solve this as I'm trying to keep this a solely react application.

Thanks

You can open in new window with window.open by setting the target as _blank. Also, it will return an pop-up instance so you can store it in you state and close it whenever you want.

 const popup = window.open(twitterUrl, '_blank', 'width: 580px, height: 690px'); popup.close() // when you need it

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