首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >HTML下拉列表在IE6中不能工作

HTML下拉列表在IE6中不能工作
EN

Stack Overflow用户
提问于 2017-12-27 00:07:03
回答 3查看 0关注 0票数 0

因此,我使用一个HTML选择框和一个国家列表以及一个按钮来打开一个小窗口,其中包含HTML选择框中所选项目的更多细节。

我是这样做的(我对这里的任何愚蠢行为表示歉意,我对Javascript还是很陌生的):

代码语言: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中就不行了。任何帮助都将不胜感激!

最新情况:因此,我尝试了下面的三种方法,替代弹出函数在这两种浏览器中都无法工作,并替换了文档。getElementById行没有改变任何事情,在Firefox中仍然很好,在IE中没有。

EN

回答 3

Stack Overflow用户

发布于 2017-12-27 08:03:37

代码语言:javascript
复制
document.getElementById("countrylist").value;

需要:

代码语言:javascript
复制
document.getElementById("countrylist")[document.getElementById("countrylist").selectedIndex].value;
票数 0
EN

Stack Overflow用户

发布于 2017-12-27 08:17:39

我就是这样修好的:

代码语言:javascript
复制
function popUp() 
{
   var c = document.getElementById("countrylist");
   var countryName = c.options[c.selectedIndex].text;
   var 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");
}

这在IE6和FF3中都是有效的。

无论如何,谢谢帮助!

票数 0
EN

Stack Overflow用户

发布于 2017-12-27 09:46:58

你遇到的问题是国名的获得。我会将您的弹出功能更改为:

代码语言:javascript
复制
function popUp() {   

  var e = document.getElementById("countrylist"); 

  var countryName = e.options[e.selectedIndex].value; 

  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");

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/-100000017

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档