You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.07 10:35:17