为什么在下面的 onclick 事件处理程序中使用“return”,似乎在按钮的 onclick 事件中有或没有返回规范的情况下都起作用?
input type="radio" name="radCPUSpeed" value="6 Ghz"
onclick="return radCPUSpeed_onclick(2)"
Run Code Online (Sandbox Code Playgroud)
该函数似乎没有做任何事情,为什么上面的输入声明中需要 return ?
function radCPUSpeed_onclick(radIndex)
{
var returnValue = true;
if (radIndex == 1)
{
returnValue = false;
alert("Sorry that processor speed is currently unavailable");
// Next line works around a bug in IE that doesn't cancel the
// Default action properly
document.form1.radCPUSpeed[radCpuSpeedIndex].checked = true;
}
else
{
radCpuSpeedIndex = radIndex;
}
return returnValue;
}
Run Code Online (Sandbox Code Playgroud) javascript ×1