<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>
Alcuni valori utili di target
potrebbero essere 'window'
(la finestra corrente) o 'top'
(per uscire da un set di frame o iframe). Se si vuole aprire una nuova finestra, invece, è possibile utilizzare navigateTo(this, 'someWindow', true);
Il valore di '--- --- attributi' è impostato utilizzando varie proprietà come documentato here for Mozilla e here for IE. Per esempio:
'height=300,width=400,top=100,left=100,statusbar=0,toolbar=1'
fonte
2009-09-18 19:08:37
[http://www.cs.tut.fi/~jkorpela/forms/navmenu.html](http://www.cs.tut.fi /~jkorpela/forms/navmenu.html) ha una buona guida (che include alcuni buoni motivi per cui non dovresti farlo). – Quentin