0

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

10
  • Can you make a JS fiddle up of your code please, an example piece of HTML and the JavaScript. jsfiddle.net Commented Nov 14, 2012 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 Commented Nov 14, 2012 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. Commented Nov 14, 2012 at 9:45
  • It would be a lot of help BlueChippy. From the information provided it isn't possible to ascertain the reason. Commented Nov 14, 2012 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. Commented Nov 14, 2012 at 10:15

1 Answer 1

0

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).

Length of Array Differs In Internet Explorer With Trailing Comma.

hope this helps :)

1
  • Thanks, checked for trailing comma but can't see one in either actual or test code...could SP be adding one somehow? Commented Nov 14, 2012 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.