I have read the article.
I can click the "Open Windows" button to open multiple links in Chrome at once as new tabs with Code A.
At present, I hope to click the "Open Windows Of TextArea" button to open multiple links in textarea (which are http://www.msn.com and http://www.asp.net) in Chrome at once as new tabs, how can I do? Thanks!
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>
Added Content:
To berriz: Thanks!
I have to use jQuery, the code B can work well.
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>