javascript - 'this' undefined in chrome, but works in IE -


below, function works in ie, good, need work in chrome, firefox, etc well... in chrome im getting error... heres code

function loadlist(list_name) {     var olist = context.get_web().get_lists().getbytitle(list_name);     var camlquery = new sp.camlquery();     camlquery.set_viewxml('<view><query><where><geq><fieldref name=\'id\'/>' + '<value type=\'number\'>1</value></geq></where></query><rowlimit>10</rowlimit></view>');     this.colllistitem = olist.getitems(camlquery); 

... says in chrome.. "uncaught typeerror: cannot set property 'colllistitem' of undefined..

i assuming "this" .. there difference on how chrome handles 'this' , ie handles 'this'??

what can ? thank you!

your code involuntarily (or deliberately?) under strict mode due sloppy concatenation or such, means function calls without explicit receiver place undefined this value instead of global object. older ies don't recognize strict mode keeps working has before.

just change this window.

fun fact: has happened amazon too


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -