因此,我使用一个包含国家/地区列表的 HTML 选择框和一个用于打开一个小窗口的按钮,其中包含 HTML 选择框中所选项目的更多详细信息。
我是这样做的(我提前为这里的任何新 watch 示歉意,我对 Javascript 还很陌生):
//in header
<script type="text/javascript">
function popUp()
{
countryName = document.getElementById("countrylist").value;
document.write(countryName);
dest = "countries/" + countryName + ".html";
window.open(dest, 0, "toolbar=0, scrollbars=0, statusbar=0, menubar=0,resizable=0,width=400,height=400,left=440,top=312");
}
</script>
<form id="countryform">
<select id="countrylist">
<!--List of countries removed for brevity-->
</select>
<input type="button" name="countryBtn" value="Submit Query" onClick="popUp();">
</form>
这在 Firefox 中工作正常,但在 IE6 中不行。任何帮助将不胜感激!
更新:所以我尝试了下面的前两种方法,替代的弹出功能在任一浏览器中都不起作用,并且替换 document.getElementById 行没有改变任何内容,在 Firefox 中仍然可以正常工作,在 IE 中没有。
最佳答案
document.getElementById("countrylist").value;
需要:
document.getElementById("countrylist")[document.getElementById("countrylist").selectedIndex].value;
关于javascript - 我的 HTML 下拉菜单在 IE6 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/982731/