Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

Apologies for deliberately cross-posting, but I have an issue where a JavaScript array in SharePoint is showing a different length from HTML (and an incorrect one!)

SO Question


Updated original to add test javascript

share|improve this question
    
Can you make a JS fiddle up of your code please, an example piece of HTML and the JavaScript. jsfiddle.net –  Hugh Wood Nov 14 '12 at 8:40
    
Could you please give us an example on this code? It's hard to help you when we don't have the code –  Daniel Ziga Nov 14 '12 at 8:56
    
not sure the actual code is of any help...SP2010 is returning the SAME javascript array with a different length? The array is identical, the "code" is identical (it's C&P'd) - its just a <script> with an array in there. –  BlueChippy Nov 14 '12 at 9:45
    
It would be a lot of help BlueChippy. From the information provided it isn't possible to ascertain the reason. –  Hugh Wood Nov 14 '12 at 10:10
    
The main reason for this, is that you could be using a variable that is already defined, and you are redefining it. From the code we would be able see that, and correct it possibly by scoping your javascript variables properly. –  Hugh Wood Nov 14 '12 at 10:15
show 5 more comments

1 Answer 1

I would need to see your javascript code ;) rergardless if its a c&p job! what works for one doesnt mean it would work for another.

Javascript is tempramental in code where sharepoint is not as bad!

As for your code do you have a trailing comma in your code??

this guy explains the issue in more detail :) cba to re-invent the wheel lol

No. IE incorrectly interprets a single trailing comma as an elision and adds one to the length when it shouldn't (ECMA-262 sect. 11.1.4).

http://stackoverflow.com/questions/6541163/javascript-length-of-array-in-internet-explorer/6541189#6541189

hope this helps :)

share|improve this answer
    
Thanks, checked for trailing comma but can't see one in either actual or test code...could SP be adding one somehow? –  BlueChippy Nov 14 '12 at 11:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.