javascript - 我的 HTML 下拉菜单在 IE6 中不起作用

标签 javascript html internet-explorer-6

因此,我使用一个包含国家/地区列表的 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/

相关文章:

javascript - 加载时 KO 5 秒延迟破坏了我的 UI

html - 更改滚动行为以允许在较小的屏幕上查看固定元素

css - 带有绝对定位的 IE 6 错误居中 div 标签

javascript - 在 IE6 中使用一维(CSS)缩放图像时如何保持纵横比?

jquery - css 不透明度在兼容模式下的 IE6/IE7 或 IE8 中无法正常工作

javascript - 使用 Angular 空值 0 的 Html5 输入

javascript - 在事件中更改事件时如何停止传播?

javascript - 如何将两个独立变量的结果分配给第三个变量?

javascript - 在javascript中让按钮显示文本

javascript - 用于动态元素和 ajax 的 jQuery 验证插件