简体   繁体   中英

Opening “Open Link in New Tab” dialog automatically

I'm working on a table where the rows are clickable (In React).

My goal: open that dialog that you get when you right click a link, and it shows "Open Link in New Tab", etc. I would like to do this without using <a/> tag, because I can neither wrap the <tr/> tags with the link tag because of how html tables work, and I also cannot put it in the <td/> tag because I need to support a multitude of cell components which I did not define, and are being added regularly by the a dev team (I cant expect them to add links everywhere).

That being said, I've looked for this online and the best I can find is people saying to use an onClick with window.open , but I dont think that will open the dialog. Am I missing some configuration for that function or is there a better way to do this? Thank you

What you're referencing is called the context menu. You could create a custom context menu to accomplish this. However, this is not recommended. The 'open link in new tab' button in the context menu is the browsers way of saying "I recognize the element you clicked on is an attributed link. I know this goes somewhere. This will only work on tags.

I would recommend finding a way to work with the table data you're given to convert the cell in to a valid link.

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