javascript - addthis_widget.js throwing Cannot read property '_pmh' of null error on Android and Chrome -
i using javascript error logging tool log javascript errors on mobile site , seeing large number (22,000 in under month) of error:
uncaught typeerror: cannot read property '_pmh' of null
i can see addthis_widget.js code originating script.
i can tell affects mobile android , google chrome browsers, these in particular:
android 4, android 4.1, android 4.2, chrome 11, chrome 18, chrome 25, chrome 26, chrome 27, chrome mobile 18, chrome mobile 25, chrome mobile 26
i using following external javascript include:
http://s7.addthis.com/js/250/addthis_widget.js#username=xa-4b6adff375a64db9
and have following configuration object set:
<script type="text/javascript"> var addthis_config = { data_ga_property: 'ua-18721873-1', // real ga profile hidden privacy purposes data_ga_social: true }; </script> is there can prevent error occuring many times on these browsers?
i have located cause of issue , down following code.
if (window.addthis) { window.addthis = null; window._adr = null; window._atc = null; window._atd = null; window._ate = null; window._atr = null; window._atw = null; } this attempt cleanup objects lying around when moving between pages dynamically prevent memory issues.
addthis provide support problem, support department sent me following link:
http://www.addthis.com/blog/2013/05/07/a-brief-history-of-using-addthis-dynamically/#.uklx4rckyas
and following explanation/information:
along other information peers , such, i've come proper code should executed when moving virtual page virtual page such in mobile application. rather nulling of addthis related objects, must left alone.
when page url or title (or other addthis configuration option) want used our buttons changes, should execute our method:
addthis.update(type, key, value)it takes 3 parameters: type, key, value.
type either "share" or "config". key same key set according our api documentation. need know 2 keys: "url" , "title". value of course value want options have.
after have updated of options need update using method, need invoke method:
addthis.toolbox(cssselector)the cssselector going ".addthis_toolbox" if reason don't want refresh of toolboxes, can more specific it.
once have made changes code, believe our tools work , there no more "null object" related javascript errors.
you can @ jsfiddle see example of dynamically changing content: http://jsfiddle.net/j5addthis/r6utv/
Comments
Post a Comment