I have a SharePoint hosted app, and I am trying to open the new item form of a SharePoint list on host web in a modal dialog using SP.UI.ModalDialog. The dialog opens fine, but when I click save or cancel I get the following error. I think this related to cross site scripting. Does anyone know of a way to open list forms in a dialog from a app?

"Uncaught SecurityError: Failed to read the 'frame' property from 'Window': Blocked a frame with origin http://hostweb.test.com from accessing a frame with origin http://app-c959f429388742.app.test.com. Protocols, domains, and ports must match.".



Direct path not exists, but you can use the JavaScript function window.postMessage(...).

It works as follows: (ex. add new SP item from app part)

  1. Child window (on APP) send messege - some serialized JSON object with properties e
  2. Parent window (on SP) dispatch message and open dialog using client api
  3. Catch dialog result on parent window (on SP) and send message to child window (on APP)
  4. Dispatch message (on APP) and create any post action in your app part

Some resources:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.