在IE8浏览器中不支持IndexOf [英] IndexOf not Supported in IE8 Browser

查看:630
本文介绍了在IE8浏览器中不支持IndexOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中有级联下拉列表,使用jquery级联,现在我的问题是它与IE9,Firefox,Opera和Safari一起工作顺利,但不适用于IE7,IE8等任何浏览器。

I have cascaded dropdown in my application, cascaded using jquery, now my problem is it is working smoothly with IE9, Firefox, Opera and Safari but does not work with any of browsers like IE7,IE8 etc.

我浏览了问题并发现错误是由于我的jquery代码中的indexOf,我通过删除indexOf尝试了它,但它仍然给出了同样的错误..

I surfed for the problem and found that error is due to indexOf in my jquery code, i tried it by removing indexOf but still it is giving the same error..

注意:在telerik脚本中是否有任何解决方法可以删除indexOf,因为我只能在他们的脚本中找到indexOf。

Note: Is there any work around in telerik script to remove indexOf, coz new only i can find indexOf in their script.

是代码:

function OnClientSelectedIndexChanged(sender, eventArgs) {
var senderId = sender.get_id().toString();

var uniqueName = senderId.substring(senderId.lastIndexOf('_'), senderId.length);

if(senderId.indexOf("drpdwnCondition") > 0)
{
   return false;
}

var selectedItem = eventArgs.get_item();
var selectedValue = selectedItem.get_value().split('_');
$.ajax({ type: "POST", async: true,
    url: "/SalesRepresentativeMonitoring.aspx/GetData", contentType: "application/json; charset=utf-8",
    data: "{value:" + JSON.stringify(selectedValue[1]) + "}", dataType: "json",
    success: function (msg) {
        var resultAsJson = msg.d // your return result is JS array
        // Now you can loop over the array to get each object
        var cnditionCombo = $find("ctl00_ContentPlaceHolder1_radDock_C_Filter_drpdwnCondition" + uniqueName.toString());
        cnditionCombo.clearSelection();
        cnditionCombo.trackChanges();
        cnditionCombo.clearItems();
        for (var i in resultAsJson) {
            //alert(resultAsJson[i]);
            var item = new Telerik.Web.UI.RadComboBoxItem();
            item.set_text(resultAsJson[i]);
            item.set_value(resultAsJson[i]);
            cnditionCombo.get_items().add(item);
        }
        var itemAtIndex = cnditionCombo.get_items().getItem(0);  //get item in detailCB
        itemAtIndex.select();
        cnditionCombo.commitChanges();
    }
});

}

感谢你..

推荐答案

数组的 indexOf()方法 s未在IE中实现< 9.当你使用jQuery时,你可以使用 $。inArray(),例如

var arr = ["foo", "bar", "baz"],
    bazIndex = $.inArray("baz", arr), // 2
    doesntExistIndex = $.inArray("notThere", arr); // -1

这是文档: http://api.jquery.com/jQuery.inArray/

这篇关于在IE8浏览器中不支持IndexOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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