如何使用 onsubmit (在按回车时执行)创建一个表单标签,它以字符串变量形式打开一个带有给定 url 的目标窗口?
到目前为止我所拥有的:
<div id="row2">
<!-- Intranet Search -->
<form action="" onSubmit="urlGen(this);" method="get" target="_blank">
<input type="text" id="intranet" size="15" value="Search Intranet.."
onFocus="this.value = ''"
onBlur="this.value = 'Search Intranet..'" / >
</form>
<script language="javascript" type="text/javascript">
function urlGen(f)
{
var i1 = "seg1";
var i2 = f.intranet.value;
var i3 = "seg3";
var fullURL = i1 + i2 + i3;
f.action = i1 + i2 + i3;
//document.write(fullURL);
return true;
}
</script>
<br><br>
<a href="javascript: void(0)" onClick="urlGen();" target="_blank">
<div id="submit" class="out"
onMouseOver="document.getElementById('submit').className = 'over';"
onMouseOut="document.getElementById('submit').className = 'out';">
<span>Submit</span>
</div>
</a>
</div>
编辑:仍然没有解决这个问题;任何有 JavaScript 经验的人的帮助将不胜感激!