如何在Chrome中一次性打开textarea内的多个链接为新标签页?
问题描述
我已阅读了相关文章,通过以下Code A,可点击“Open Windows”按钮在Chrome中一次性打开多个链接为新标签页。目前希望点击“Open Windows Of TextArea”按钮,一次性打开textarea内的多个链接(http://www.msn.com和http://www.asp.net)为Chrome新标签页,该如何实现?感谢解答!
Code A
<html> <head> <script type="text/javascript"> function open_win() { window.open("http://www.google.com/") window.open("http://www.twitter.com/") } function open_win_textArea() { //How to do ? } </script> </head> <body> <form> <input type=button value="Open Windows" onclick="open_win()"> </form> <br /> <textarea id="textID" name="message" rows="10" cols="80"> http://www.msn.com/ http://www.asp.net/ </textarea> <br /> <br /> <form> <input type=button value="Open Windows Of TextArea" onclick="open_win_textArea()"> </form> </body> </html>
补充内容
感谢berriz!我必须使用jQuery,以下Code B可正常运行。
Code B
<script type="text/javascript"> function open_win_textArea() { let links = $('#textID').val(); // perform check for js not to break; you need to add defer as an attribute to the <script> element if (links) { let urls = links.split('\n'); urls.forEach((url) => { window.open(url); }); } } </script>
内容的提问来源于stack exchange,提问作者HelloCW
相关产品推荐
相关产品推荐

