修复:为什么我的动态SELECT不能在IE9中工作? [英] FIXED: Why is my dynamic SELECT not working in IE9?

查看:362
本文介绍了修复:为什么我的动态SELECT不能在IE9中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里有一个脚本,可以在FF14和Chrome20中正常工作。



如果您在IE9中打开页面并更改首先下拉(综合搜索)为Word TM,然后第二个下拉列表将变为空白。



在其他浏览器中,行为是正确的,并且在选择菜单中添加了两行额外的内容。

任何想法为什么IE9不喜欢这个,以及如何解决它?



感谢下面的评论,问题现在已经修复!

解决方案

您有一个ID为report_options的SELECT元素(z),并尝试使用innerHTML更改其选项。这在IE9中不起作用。使用z.options.remove(zeroBasedPosition)去除选项和z.options.add(OPTION),其中OPTION是一个DOM元素创建和添加的:

  var option = document.createElement(OPTION); 
option.text =你的文字;
option.value =你的价值;
z.options.add(option);


I have a script on here that works fine in FF14 and Chrome20.

A part of it is not working in IE9.

If you open the page in IE9 and change the first dropdown (Comprehensive Search) to "Word TM", then the second dropdown will become empty.

In other browsers, the behavior is correct, and it adds two extra lines to the select menu.

Any idea why IE9 does not like this and how to fix it?

Thanks to the comments below, the issue has now been fixed!

解决方案

You have a SELECT element (z) with id "report_options" and you try to change its options using innerHTML. This is no working in IE9. Use z.options.remove(zeroBasedPosition) to remove options and z.options.add(OPTION) where OPTION is a DOM element created and added by:

var option = document.createElement("OPTION");
option.text = "your text";
option.value = "your value";
z.options.add(option);

这篇关于修复:为什么我的动态SELECT不能在IE9中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆