相关疑难解决方法(0)

IE8不支持的JavaScript函数列表

我最近在IE8上为前端做了很多JavaScript编码,并且遇到了一些由IE8缺乏支持功能引起的问题.

以下是一些功能:

 (1)indexOf() 参见讨论和解决方案
 (2)base64() 参见source
 (3)String.trim() 参见讨论和解决方案
 (4)history.pushstate 参见讨论和解决方案
 (5)map() 参见讨论和解决方案
 (6)ArrayBuffer(7)bind(8)Create(9)DataView( 10)每(11)个过滤器......

如果您遇到任何帮助他人的话,请在此列表中添加更多内容.
谢谢

javascript internet-explorer-8

7
推荐指数
1
解决办法
2626
查看次数

仅在IE(8)中出现jQuery错误 - "对象不支持..."

我在jQuery中有这段代码(AJAX).

$.get('someScript.php?lat=' + clickedLatLng.lat() + '&lon=' + clickedLatLng.lng() + '&value=5', doSomething);
Run Code Online (Sandbox Code Playgroud)

这是一个功能(在Google地图上显示一个图标并更改输入字段中的某些值).

function doSomething(data) {
    data = data.trim();
    data = data.split(","); 
    var stopName = data[0];
    var stopLat = data[1];
    var stopLon = data[2];

    $("#start").val(stopName);

    if (startMarker == null) {
        startMarker = new google.maps.Marker({
                            position: new google.maps.LatLng(stopLat,stopLon),
                            map: map,
                            zIndex: 2,
                            title: stopName,
                            icon: startImage 
        });
    } else {
        startMarker.setPosition(new google.maps.LatLng(stopLat,stopLon));
    }
}
Run Code Online (Sandbox Code Playgroud)

但它适用于IE以外的所有浏览器,在我的IE 8中.我没有在IE 6/7中测试它.它弹出这个错误......

IE 8中的jquery错误

我查看了jquery.js,这是它打破的功能......

            // resolve with given context and args
            resolveWith: function( context, args ) …
Run Code Online (Sandbox Code Playgroud)

ajax jquery google-maps internet-explorer-8

6
推荐指数
1
解决办法
7675
查看次数

是text.trim()真的不能在IE8中工作

当我在chrome和firefox中测试我的网页时,它们工作正常.但在IE中它没有用.

我找到

(" .class li").text().trim() 没有在IE工作,他给我错误

Object不支持此属性或方法.但在FF和铬他们工作正常.我是不是有点不对劲.

jquery

4
推荐指数
1
解决办法
6820
查看次数

为什么Internet Explorer不喜欢这个jQuery?

在调试一些在IE中不起作用的jQuery时,我发现了以下错误消息:

var item = $("#item_"+ itemArray[itemIndex]).find('a').text().trim();

Object doesn't support this property or method (script.js, line 100, character 2)
Run Code Online (Sandbox Code Playgroud)

character 2没有道理给我.根据显示的文字character 2将是字母a,var但当然没有任何意义.

(我不应该使用var?)

我知道jQuery在某种程度上有效,或者脚本无法在我的页面上实现这一点.

javascript jquery internet-explorer

4
推荐指数
1
解决办法
1815
查看次数

Object仅在IE8上不支持此属性或方法

此代码在Chrome,FF,Safari,IE9上运行,但在IE8上我收到此错误:

消息:对象不支持此属性或方法行:80字符:7代码:0

这就是它停止的代码:(第80行是"return ["但开发人员工具调试器突出显示下面的所有代码)

return [
    {
        title:'Edit',
        customClass:'actionEdit',
        action:{
            type:'getLink',
            url:'/admin/products/edit/'+data.id()+''
        }
    },
    {
        title:'Attaches',
        customClass:'actionAttaches',
        action:{
            type:'getLink',
            url:'/admin/attaches/index/product/'+data.id()+''
        }
    },
    {
        title:'Delete',
        customClass:'actionDelete',
        action:{
            type:'postLink',
            url:'/admin/products/delete/'+data.id()+'',
            confirm:'Are you sure you want to delete %s?',
            arg:$('#ProductAdminIndexList #'+data.id()+' .productId').text().trim()
        }
    }
];
Run Code Online (Sandbox Code Playgroud)

我发现其他类似的情况,但我不知道为什么会发生,如何解决这个问题.

javascript internet-explorer-8

4
推荐指数
1
解决办法
7132
查看次数

在jquery中使用.Val()时出错

我正在使用JQuery,我已经获得了JQuery Code示例.

JQuery代码:

 $.ajax({  
        type: "POST",
        url: "Login.aspx",  // Send the login info to this page
        data: str,  
        success: function(result)
        {  
             // Show 'Submit' Button
            $('#loginButton').show();

            // Hide Gif Spinning Rotator
            $('#ajaxloading').hide();  

            var resLength = (result).val().trim().length;
            alert(resLength);
            if(resLength!=0)
            {

                var arr = result.split(",");
                var fname = arr[0];
                var lname = arr[1];
                var activeCardNo = arr[2];
                var multipleTier = arr[3];
                var activeStatus = arr[4];
                var access = arr[5];
            }
        }
    }); 
Run Code Online (Sandbox Code Playgroud)

在上面的代码示例中,当我尝试在下面的行中使用.val()

var resLength = (result).val().trim().length;
Run Code Online (Sandbox Code Playgroud)

它给出错误"result.val不是函数",如果我只使用 …

jquery

3
推荐指数
1
解决办法
2748
查看次数

IE8中的JQuery .filter()

看起来IE8不支持Jquery .filter()方法 - 为什么.filter()在Internet Explorer 8中不起作用?

我有以下代码过滤下拉列表

if($('#deliveryPostcodeEstimator').length > 0) {
        $('.shippingregionselector').hide();
        $('#deliveryPostcodeEstimator')
            .blur(function() {
                //Set to default
                $('select[name=country] option:last').prop('selected', true);
                //var defaultPostcode = 'GL50';
                //$("select[name=country] option").filter(function() {
                //  return $(this).text() == defaultPostcode; 
                //}).prop('selected', true);
                //Set to matching postcode value if set
                $('select[name=country] option').filter(function(index) { 
                    return ($(this).text() == $('#deliveryPostcodeEstimator').val().toUpperCase().substring(0,4).trim()) 
                }).prop('selected', true);
                //Submit
                var thisForm = $(this).closest("form");
                thisForm.submit();
            })
            .keyup(function() {
                $(this).val($(this).val().toUpperCase());
            });
        $('button.pcodechange').click(function() {
            var thisForm = $(this).closest("form");
            thisForm.submit();
        });
    }
Run Code Online (Sandbox Code Playgroud)

问题是

return ($(this).text() == $('#deliveryPostcodeEstimator').val().toUpperCase().substring(0,4).trim()) 
Run Code Online (Sandbox Code Playgroud)

这给出了以下错误

Object doesn't …

arrays jquery filter internet-explorer-8

3
推荐指数
1
解决办法
2587
查看次数

旧版IE上的Jquery问题

我在document.ready函数中有以下语句:

  if($("sidebar ").html().trim().length == 0)
  {
    $("sidebar").append("<p>&nbsp;&nbsp;&nbsp;The sides..</p>"); 
  };
Run Code Online (Sandbox Code Playgroud)

它在IE 9中工作正常,但只要我选择IE 8(浏览器和文档标准),脚本就会停止工作并发出以下错误:

SCRIPT5007: Unable to get value of the property 'trim': object is null or undefined 
application-e51c9eee7d22e9644481115dc1fedd5f.js, line 7 character 17578
Run Code Online (Sandbox Code Playgroud)

我在调试模式下查看了.js,看到上面的语句转换为:

$("sidebar ").html().trim().length==0&&$("sidebar").append("<p>&nbsp;&nbsp;&nbsp;The sides..</p>")
Run Code Online (Sandbox Code Playgroud)

如何防止此错误?请注意,我确实看到该节点存在于呈现的页面中.

我认为可能只是提到shiv5.html可能不足以照顾IE的特性.所以,我通过sprockets添加了modernizr.js,并在我的布局中添加了class ="no-js".在IE <9中仍然没有运气.

我错过了什么?我还能做些什么来获得微软霸主的青睐?

javascript jquery internet-explorer ruby-on-rails cross-browser

1
推荐指数
1
解决办法
1277
查看次数

此代码在IE中不起作用

嗨所以我有这个jQuery/JS脚本.这基本上采用编码的URL字符串并解析它并将变量值保存到变量中.

基本上是PHP的$ _GET.

function getUrlVars() 
{
 var map = {}; 
 var parts = window.location.search.replace(/[?&]+([^=&]+)(=[^&]*)?/gi, 

   function(m,key,value) 
     { map[key] = (value === undefined) ? true : value.substring(1); }); 

 return map; 
}
Run Code Online (Sandbox Code Playgroud)

基本上这个脚本做我想要的.从此URL字符串:

/autopop.html?Email=test%40test.com&LastName=Test+last&&FirstName=+Test+First
Run Code Online (Sandbox Code Playgroud)

我得到了价值观:

Email = test%40test.com

LastName = Test+last

FirstName = +Test+First
Run Code Online (Sandbox Code Playgroud)

我想要做的是使用此信息在同一页面上自动填充表单.(我知道你在想什么服务器端脚本会是一个更好的解决方案,但老板说我们无法访问它,相信我,我已经尝试过了)

长话短说,这是我的其余代码:

var keys = getUrlVars();

$(document).ready(function(){
    var fname = keys['FirstName'].replace(/\+/g , " ").trim();
    var lname = keys['LastName'].replace(/\+/g , " ").trim();
    var email = decodeURIComponent(keys['Contact0Email'].replace(/\+/g , " ")).trim();
    $("#Email").val(email);
    $("#FirstName").val(fname);
    $("#LastName").val(lname);
});
Run Code Online (Sandbox Code Playgroud)

这段代码完成了工作.除了一个浏览器外.IE浏览器.

IE不支持decodeURIComponent或所以我读过.无论如何,我尝试使用其他功能,decodeURI并且escape …

javascript jquery internet-explorer cross-browser

0
推荐指数
1
解决办法
4624
查看次数

从空格中提取数字

价值是这样的:12 23 345 3454 21.

我需要从中获取数字并存储到数组中,以便我的数组看起来像 values = new Array(12,23,345,3454,21);.

我的问题是我可以删除白色空格,但它来了1223345345421.

javascript regex

0
推荐指数
1
解决办法
87
查看次数