IE9中没有为select元素调用内联处理程序

时间:2014-07-28 17:30:38

标签: javascript internet-explorer javascript-events

我试图找出生产机器上IE9中可能导致问题的原因。我们有一个<select>组合框,其中包含一个内联更改处理程序(我意识到这是一个不好的做法,但我现在无法做任何事情)但是没有被调用。

HTML如下所示(从开发工具中复制)

<select name="propertyName" id="propertyName" onchange="Workflows.CoreSetPropertyActivity._field_OnChange();">
  <option value="Property_103156" title="Boolean Prop" selected="selected">Boolean Prop</option>
  <option value="Property_103072" title="String Prop A">String Prop A</option>
</select>

在与客户的webex上,我在Workflows.CoreSetPropertyActivity._field_OnChange()中放置一个断点并且没有被调用(在IE9中)。如果我从控制台手动调用它,一切正常。

我们使用IE8进入完全相同的机器,并且Workflows.CoreSetPropertyActivity._field_OnChange()被调用,一切正常。

我认为唯一可能相关的其他信息是下拉列表是动态创建的。

有人碰到类似的东西吗?有什么尝试的建议吗?也许在IE中可以打破这个法术的一些设置?

创建HTML

使用以下代码将选择添加到页面中。要插入的HTML看起来像

<div class="wrapper">

    <ul id="setStateConditions">
        <li class="setStateLabel">Property Name</li>
        <li class="setStateContent">
            <select name='propertyName' id='propertyName'  onchange='Workflows.CoreSetPropertyActivity._field_OnChange();' >
<option value='Property_103156' title='Boolean Prop'  selected='selected' >Boolean Prop</option>
<option value='Property_103072' title='String Prop A' >String Prop A</option>
</select>
<br />
<input id="filterExpression" name="filterExpression" type="hidden" value="" />

<script type="text/javascript">

    _condition_strings = 
    {
        "equal": "Is Equal To",
        "not_equal": "Is Not Equal To",
        "contains": "Contains",
        "less_than": "Is Less Than",
        "less_than_or_equal": "Is Less Than or Equal To",
        "greater_than": "Is Greater Than",
        "greater_than_or_equal": "Is Greater Than or Equal To",
        "literal": "Literal Value",
        "is_collected": "Has Been Collected",
        "is_not_collected": "Has Not Been Collected"
    }; 


    function getLeftUrl(leftMenu, value) {
        var selectedProperty = $('#propertyName').val() || '';

        return "/Property/ReflectionMenuLeftByRelation/" + workflow.data_provider_id
             + "?relationSafeName=" + selectedProperty 
             + "&nameWithParents=" + value; 
    };

    function getRightUrl(rightMenu, value) {
        //Find value of left to filter 
        var selectedProperty = $('#propertyName').val() || '';
        var leftMenuValue = rightMenu.item.prevAll(".left-operand").eq(0).attr("value") || '';

        return "/Property/ReflectionMenuRightByRelation/" + workflow.data_provider_id
             + "?relationSafeName=" + selectedProperty
             + "&nameWithParents=" + value
             + "&compatableWithSafeName=" + leftMenuValue; 
    };

    function getOperatorUrl(operatorMenu, value) {
        //Find value of left in order to get the correct list of 

        var selectedProperty = $('#propertyName').val() || '';
        var leftMenuValue = operatorMenu.item.prevAll(".left-operand").eq(0).attr("value") || '';

        return "/Property/OperatorsByRelation/" + workflow.data_provider_id
             + "?relationSafeName=" + selectedProperty
             + "&compatableWithSafeName=" + leftMenuValue; 
    };

    function getLiteralControlUrl(rightMenu, startValue, leftMenuValue, uniqueRowCounter) {
        var selectedProperty = $('#propertyName').val();
        var leftMenuValue = leftMenuValue || rightMenu.item.prevAll(".left-operand").eq(0).attr("value") || '';

        return "/Property/PropertyValueByRelation/" + workflow.data_provider_id
             + "?relationSafeName=" + selectedProperty
             + "&safeNameWithParents=" + leftMenuValue
             + "&domId=literal_" + uniqueRowCounter
             + "&startValue=" + startValue; 
    }

    function getDereferenceUrl(menu){
        var selectedProperty = $('#propertyName').val() || '';

        return "/Property/ResolveSafeNameToDisplayNameByRelation/" + workflow.data_provider_id
             + "?relationSafeName=" + selectedProperty
             + "&safeNameWithParents=" + menu.getValue();
    }






    $(function() {
        ExpBuilder.init($("#filterExpression").val());

        //Move to a wider space
        $("#expressionBuilder").appendTo("#propertyValueWide");
    });

onSaveParameters = function() {
    //When User clicks save
    if ($("#expressionBuilder").is(":visible")) {
        //TODO check for empties    
        $("#filterExpression").val(ExpBuilder.getJson())
        Workflows.CoreSetPropertyActivity._UpdateJson()
    }
}

ExpBuilder.errorNoCondition = 'There are no conditions.';

</script>

<div id="expressionBuilder" style="display:none;">
    <div class="clr"></div>
    <div class="condLoader"></div>
    <div class="condWrapper" style="display:none;">
        <div class="conditionGroup condTier1 condTop" >
            <div class="conditionGroupBullet"><div><img src="/images/spacer.gif" alt="" width="10" height="3"></div></div>
            <div class="conditionHead">
                <div class="conditionOperation">
                    <select id="100" name="anyAll">
                        <option value="or">Any</option>
                        <option value="and">All</option>
                    </select> 
                </div>
                <div class="closeBtn"><img src="/images/buttons/close.png" class="closeGroupImg" alt=""></div>
            </div>
            <div class="conditionContent"></div>

            <ul class="buttons buttonsLeft">
                <li>
                    <a href="#" class="btnAddCondition"><span>Create Condition</span></a>
                </li>
                <li>
                    <a href="#" class="btnAddConditionGroup"><span>Create Group Condition</span></a>
                </li>                
            </ul>
        </div> 
    </div>
    <ul class="buttons buttonsLeft hidden">
        <li>
            <a href="#" class="btnAddCondition" onclick="CreateJsonBase();return false;"><span>Create Json</span></a>
        </li>       
        <li>
            <a href="#" class="btnAddCondition" onclick="ExpBuilder.LoadData();return false;"><span>Load Json</span></a>
        </li>                     
    </ul>

    <!-- Template for Conditions -->
    <div class="condition hidden">
        <div class="conditionBullet"><div><img src="/images/spacer.gif" alt="" width="10" height="3"></div></div>
        <div class="conditionItem">

            <a href="#" class="left-operand"></a> 
            <a href="#" class="operator"></a> 
            <a href="#" class="right-operand"></a>
            <span class="right-literal"></span>

        </div>
        <div class="closeBtn"><img src="/images/buttons/close.png" class="closeImg" alt=""></div>
        <div class="clr"></div>
    </div>

</div>

<span id="propertyValue">
    <input type="checkbox" id="setDefault" onclick="Workflows.CoreSetPropertyActivity._field_OnChange();" />
    <label for="setDefault">Default Value</label>

    <span id="defaultOptions"> 
        <input id="setPropertyValue" name="setPropertyValue" onblur="Workflows.CoreSetPropertyActivity._UpdateJson();" onchange="Workflows.CoreSetPropertyActivity._UpdateJson();" onkeypress="Workflows.CoreSetPropertyActivity._UpdateJson();" type="text" value="" /><br />
        <input type="checkbox" id="allowEdit" onclick="Workflows.CoreSetPropertyActivity._field_OnChange();" />
        <label for="allowEdit">Allow Edit</label> <br />
    </span>
</span>

<div>
    <input type="checkbox" id="isRequired" onclick="Workflows.CoreSetPropertyActivity._field_OnChange();" checked/> 
    <label for="isRequired">Is Required</label>
</div>
<input type="text" id="PropertyName" class="hidden" />


        </li>
    </ul>


    <div id="propertyValueWide"></div>


    <div class="clr"></div>
</div>

它已添加到页面中使用(其中htmlString包含我上面显示的HTML)

$(htmlString).appendTo('.settings-form');

1 个答案:

答案 0 :(得分:0)

事实证明,问题是客户正在运行IE9 with the release to manufacturing version (RTM),这是GA发布之前的Internet Explorer预发布版。

客户在另一台机器上安装了IE9,问题就消失了。我非常有信心,当他们在那台机器上重新安装IE时,它将被修复。

感谢大家投球。