One Drive JS File Picker : error in window's opener

独自空忆成欢 提交于 2019-12-07 22:53:47

问题


I am trying to implement the One Drive File Picker as instructed

The One Drive window opens fine and you select a file but then doesn't return to my site, i get a continuous waiting spinner.

If i look in the Chrome console I am seeing multiple lines of the following

[OneDriveSDK] error in window's opener, pop up will close. Array[1]

And then at the end

Uncaught RangeError: Maximum call stack size exceeded OneDrive.js:2

My Code

<button id="onedrive">Open from OneDrive</button>

<script type="text/javascript" src="https://js.live.net/v7.0/OneDrive.js"></script>

...

$(document).ready(function() {
    $("#onedrive").click(function () {
        console.log("One Drive Clicked");
        var odOptions = {
            clientId: "########",
            action: "share",
            multiSelect: false,
            openInNewWindow: true,
            advanced: {},
            success: function (files) {
                console.log(files);
            },
            cancel: function (c) {
                console.log(c);
            },
            error: function (e) {
                console.log(e);
                alert(e);
            }
        };
        OneDrive.open(odOptions);
    });
});

回答1:


There was a form behind the button which was causing the form to submit, and open the OneDrive Window at the same time meaning it couldn't return.

Button has now been changed to an input type="button"

<input type="button" id="onedrive" name="onedrive" value="Choose from OneDrive">


来源:https://stackoverflow.com/questions/38434283/one-drive-js-file-picker-error-in-windows-opener

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!