我正在使用 for 循环打开几个 url,但是它只打开数组中的第一项。我曾尝试使用 for ( i in array) 但它得出了相同的结果。
<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function launchproducts (form) {
var input_from_user = form.inputbox.value;
var product_numbers;
product_numbers = input_from_user.split(";",100000);
for ( var i = 0; i < product_numbers.length; i++) {
launch_code = "http://www.youtube.com/results?search_query=" + product_numbers[i];
window.open(launch_code, '_blank');
}
}
</SCRIPT>
</HEAD>
<BODY>
<FORM NAME="myform" ACTION="" METHOD="GET">Enter product numbers: <BR>
<INPUT TYPE="text" NAME="inputbox" VALUE=""><P>
<INPUT TYPE="button" NAME="button" Value="Click" onClick="launchproducts(this.form)">
</FORM>
</BODY>
</HTML>