我错过了什么吗?该按钮应该基于无线电选择启动各个站点
function navigateSite(){
var getUrl = document.querySelector('input[name = "myRadio"]:checked').value
console.log(getUrl);
}

<INPUT TYPE="radio" id="Orange" name="myRadio" value="www.google.com"> Orange
<INPUT TYPE="radio" id="Apple" name="myRadio" value="www.mozilla.com"> Apple
<INPUT TYPE="radio" id="Mango" name="myRadio" value="www.microsoft.com"> Mango
<button onclick="navigateSite()">Select</button>
&#13;
答案 0 :(得分:1)
弹出窗口仅在代码段之外工作
function navigateSite(){
var getUrl = document.querySelector('input[name = "myRadio"]:checked').value
console.log(getUrl);
window.open(getUrl, getUrl, "width=600,height=500");
}
&#13;
<INPUT TYPE="radio" id="Orange" name="myRadio" value="www.google.com"> Orange
<INPUT TYPE="radio" id="Apple" name="myRadio" value="www.mozilla.com"> Apple
<INPUT TYPE="radio" id="Mango" name="myRadio" value="www.microsoft.com"> Mango
<button onclick="navigateSite()">Select</button>
&#13;