Anonymous Authentication - JavaScript API

I am trying to using Javascript API using Anonymous Authentication. I am able to open a report using the webplayer link(Example: http://server:port/spotfire/wp/OpenAnalysis?file=/SampleAnonymousReport) but not able to open the same report using Javascript API.  Error: 

Uncaught DOMException: Failed to execute 'postMessage' on 'Window': Invalid target origin '' in a call to 'postMessage'.
    at Object.proxy.postMessage (http://server:port/spotfire/wp/render/vruIfgt7S-RUTAmUMd/Spotfire.Dxp.We...)

(1) Answer