<script type="text/javascript">
function navigateTo(sel, target, newWindow) {
var url = sel.options[sel.selectedIndex].value;
if (newWindow) {
window.open(url, target, '--- attributes here, see below ---');
} else {
window[target].location.href = url;
}
}
</script>
<select onchange="navigateTo(this, 'window', false);">
<option selected="selected" value="http://www.example.com/#X">Change to URL X</option>
<option value="http://www.example.com/#Y">Change to URL Y</option>
</select>
target 的一些有用值可能是'window'(当前窗口)或'top'(打破框架集或 iframe)。如果你想打开一个新窗口,你可以使用navigateTo(this, 'someWindow', true);
'--- attributes ---' 的值是使用记录在 here for Mozilla 和 here for IE 中的各种属性设置的。例如:
'height=300,width=400,top=100,left=100,statusbar=0,toolbar=1'