javascript - IE9 Error 80020102, using vbscript Preserve keyword with doctype strict - Stack Overflow

I'm using IE9 beta with the test code below and i encounter an 80020102 error when vbscript tries

I'm using IE9 beta with the test code below and i encounter an 80020102 error when vbscript tries to append to the array. If I run this in quirks mode it seems to work.

Not knowing if this is an MS issue or something improper I'm doing, I've submitted it to IE9s bug depot. Does anyone have a suggestion on a work around?

I'd post the full html, but it always looks malformed in the preview.

-- VBscript part ---    
Function getBlankArray() 
   getBlankArray = Array() 
End Function

Function appendArray(arr, val) 
   redim preserve arr(ubound(arr) + 1) 
   arr(ubound(arr)) = val 
   appendArray = arr 
End Function

-- javascript part --- 
function test()
{
    var contextKeysArray = getBlankArray();
        var jscontextKeysArray = new Array();
    for(var x=0; x < 10; x++)
    {

        jscontextKeysArray[x] = x;

    }

    for(i = 0; i < jscontextKeysArray.length; i++)
    {
            contextKeysArray = (appendArray(contextKeysArray, jscontextKeysArray[i]));
    }

}

I'm using IE9 beta with the test code below and i encounter an 80020102 error when vbscript tries to append to the array. If I run this in quirks mode it seems to work.

Not knowing if this is an MS issue or something improper I'm doing, I've submitted it to IE9s bug depot. Does anyone have a suggestion on a work around?

I'd post the full html, but it always looks malformed in the preview.

-- VBscript part ---    
Function getBlankArray() 
   getBlankArray = Array() 
End Function

Function appendArray(arr, val) 
   redim preserve arr(ubound(arr) + 1) 
   arr(ubound(arr)) = val 
   appendArray = arr 
End Function

-- javascript part --- 
function test()
{
    var contextKeysArray = getBlankArray();
        var jscontextKeysArray = new Array();
    for(var x=0; x < 10; x++)
    {

        jscontextKeysArray[x] = x;

    }

    for(i = 0; i < jscontextKeysArray.length; i++)
    {
            contextKeysArray = (appendArray(contextKeysArray, jscontextKeysArray[i]));
    }

}
Share edited Feb 10, 2011 at 17:26 Matt Ball 360k102 gold badges653 silver badges720 bronze badges asked Feb 10, 2011 at 17:24 ChrisChris 1111 silver badge3 bronze badges 3
  • Have a read over stackoverflow./editing-help for formatting issues. – Matt Ball Commented Feb 10, 2011 at 17:26
  • Why are you mixing JS and VBScript code ??? Stick to JS code is IMHO better. In JS, you can call the Array.push(val) method instead of this ugly VBScript appendArray(arr, val) function. – CedX Commented Dec 15, 2011 at 16:13
  • 1 no error in IE8 in strict mode so indeed an IE9 matter i agree with Cédric, both languages have their merits but in arrays Javascript surely is better – peter Commented Jan 11, 2012 at 21:52
Add a ment  | 

3 Answers 3

Reset to default 1

just try to add this line on top of page if you using html page.

<! DOCTYPE html >

Have you tried using patibility mode?

<meta http-equiv="X-UA-Compatible" content="IE=8; IE=7; IE=5" >

http://msdn.microsoft./en-us/library/cc288325%28v=vs.85%29.aspx

I also agree with the ments that if you can get away from the vbscript and use a javascript-only solution you will be better off.

Here is your code cleaned up from VBScript:

function test() {
    var contextKeysArray = [], jscontextKeysArray = [];
    for (var x = 0; x < 10; x++) {
        jscontextKeysArray[x] = x;
    }

    for (var i = 0; i < jscontextKeysArray.length; i++) {
        contextKeysArray.push(jscontextKeysArray[i]);
    }
}

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744908992a4600431.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信