Google Picker无法在补充工具栏中添加

时间:2015-06-26 07:26:53

标签: google-apps-script

我正在使用Add On Sidebar中的Google Picker。我几乎使用了选择器教程中提供的所有代码,它运行得非常好。

但是,当Picker模式对话框显示时,它仅限于Add On Side栏的尺寸。让它无法使用。我希望它仅限于Google文档窗口(我的侧边栏附加到其中)的尺寸。这是主要代码:

function createPicker(token) { 
    if (pickerApiLoaded && token) {

      var picker = new google.picker.PickerBuilder()
          // Instruct Picker to display only spreadsheets in Drive. For other
          // views, see https://developers.google.com/picker/docs/#otherviews
          .addView(google.picker.ViewId.SPREADSHEETS)
          // Hide the navigation panel so that Picker fills more of the dialog.
          .enableFeature(google.picker.Feature.NAV_HIDDEN)
          // Hide the title bar since an Apps Script dialog already has a title.
          .hideTitleBar()
          .setOAuthToken(token)
          .setDeveloperKey(DEVELOPER_KEY)
          .setCallback(pickerCallback)
          // Instruct Picker to fill the dialog, minus 2 pixels for the border.
          .setSize(DIALOG_DIMENSIONS.width - 2,
              DIALOG_DIMENSIONS.height - 2)
           .build();

      //picker.setOrigin(window.location.protocol + '//' + window.location.host);     


      picker.setVisible(true);

    } else {
      showError('Unable to load the file picker.');
    }
  }

我认为以下setOrgin()可能有所帮助。但它实际上阻止了选择器的工作。

setOrigin(window.location.protocol + '//' + window.location.host)  

1 个答案:

答案 0 :(得分:0)

You need to set the origin to docs.google.com.

            .setOrigin('https://docs.google.com')