I think the problem is that you are opening it in browser window, not inside Office app. I encountered the same problem with Excel add-in. The api should not work properly outside of Office applications. If you need your application to work outside of Excel - you can check if the web-page is opened inside Office application, and only in that case load office api.