HTML:选择菜单作为导航菜单

时间:2014-07-05 00:54:21

标签: html select

<select id="touchsplashmenu" onchange="window.open(this.value,'','');">
    <option value="">Choose your page</option>
    <option value="page1.html">Page 1</option>
    <option value="page2.html">Page 2</option>
    <option value="page3.html">Page 3</option>
</select>

现在每个页面都会在新窗口中打开。如何更改此设置以便在当前浏览器窗口中打开页面?

3 个答案:

答案 0 :(得分:1)

这对你有用吗?

<select id="touchsplashmenu" onchange="location.href=this.value">
    <option value="">Choose your page</option>
    <option value="www.google.com">Page 1</option>
    <option value="www.facebook.com">Page 2</option>
    <option value="www.google.com">Page 3</option>
</select>

答案 1 :(得分:1)

<强>替换

onchange="window.open(this.value,'','');"

。通过

onchange="window.open(this.value,'_self');"

此外,如果您在“选择页面”上获得404页面...请尝试将其设置为value="#"

更新HTML

<select id="touchsplashmenu" onchange="window.open(this.value,'_self');">
    <option value="#">Choose your page</option>
    <option value="page1.html">Page 1</option>
    <option value="page2.html">Page 2</option>
    <option value="page3.html">Page 3</option>
</select>

答案 2 :(得分:0)

尝试

<select id="touchsplashmenu" onchange="window.open(this.value,'_self');">

请参阅W3schools.com