javascript Microsoft JScript 运行时错误:在 IE 中访问被拒绝 Dropbox.js
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14749522/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Microsoft JScript runtime error: Access is denied Dropbox.js in IE
提问by user1969032
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dropbox.js/0.9.0/dropbox.min.js"></script>
Hi am using above file to access dropbox functions. It contain all the dropbox functions. i included this one to my application and i
used the below code to upload a file to dropbox using writefile function.
This was working fine in chrome and Mozilla browser but in IE its getting an error.
The error is: "Microsoft JScript runtime error: Access is denied".
Please anyone help me how to resolve thid IE Error and tell me the reason why this error coming only for IE Browser?
您好,正在使用上述文件访问保管箱功能。它包含所有保管箱功能。我将这个包含在我的应用程序中,并使用以下代码使用 writefile 函数将文件上传到保管箱。
这在 chrome 和 Mozilla 浏览器中运行良好,但在 IE 中出现错误。
错误是:“Microsoft JScript 运行时错误:访问被拒绝”。
请任何人帮助我如何解决这个 IE 错误并告诉我为什么这个错误只出现在 IE 浏览器中?
var UploadToDropbox = new Dropbox.Client({ key: consumerKey, secret: consumerSecret, token: accessToken, tokenSecret: accessTokenSecret, dropbox: true });
UploadToDropbox.authenticate(function (error, UploadToDropbox) {
if (error) {
alert('Something wrong here.');
}
else {
UploadToDropbox.writeFile("HelloWorld.txt", "Hello, world!\n", function (error, stat) {
if (error) {
return showError(error); // Something went wrong.
}
alert("File saved to your dropbox successfully. ");
});
}
});
Hi thank you for your reply my question and i tried like that but still that same error coming.
嗨,谢谢你回答我的问题,我试过这样但仍然出现同样的错误。
Ok now what should i do for resolve this error.
好的,现在我应该怎么做才能解决这个错误。
and i tried with this also
我也试过这个
<script type="text/javascript">
// Hack to make dropbox.js works in IE8, IE9.
if (!window.btoa) window.btoa = base64.encode;
if (!window.atob) window.atob = base64.decode;
</script>
but same error.
但同样的错误。
回答by The Dark Knight
Open IE->Tools-->InternetOptions
打开IE->工具-->Internet选项
In Security Tab->select Zone as Internet-->Click Custom Level Button---> Check "Enable" in Access data source across Domains under Miscellaneous.
在安全选项卡-> 选择区域为 Internet--> 单击自定义级别按钮 ---> 在杂项下的跨域访问数据源中选中“启用”。
It seems that IE does not play well with javascript events that trigger a DOM control. So try to remove such event actions , if they are present .
IE 似乎不能很好地处理触发 DOM 控件的 javascript 事件。因此,如果存在此类事件操作,请尝试删除它们。
Usually means that you are attempting to update a property or access content that is not permitted under your current security settings.
通常意味着您正在尝试更新当前安全设置不允许的属性或访问内容。
Sometimes, it also happens due to usage of deprecated method .
有时,它也会由于使用已弃用的方法而发生。
回答by pwnall
The hack in your question is not necessary. dropbox.js packages its own implementation of atob
/ btoa
, which is used on IE <= 9. You can try it out by accessing Dropbox.Util.atob
and Dropbox.Util.atob
in the IE Developer Tools console.
你的问题中的黑客是没有必要的。dropbox.js 打包了自己的atob
/实现,btoa
用于 IE <= 9。您可以通过访问Dropbox.Util.atob
和Dropbox.Util.atob
在 IE 开发人员工具控制台中进行尝试。
base64 code: https://github.com/dropbox/dropbox-js/blob/master/src/base64.coffee
base64 代码:https: //github.com/dropbox/dropbox-js/blob/master/src/base64.coffee
First, please run the checkbox.js sample code to check your IE settings. If the sample works (you can log in, add tasks, mark them as done and remove them) then your IE settings are OK, and the problem is elsewhere.
首先,请运行 checkbox.js 示例代码以检查您的 IE 设置。如果示例有效(您可以登录、添加任务、将它们标记为完成并删除它们),那么您的 IE 设置就可以了,问题出在其他地方。
checkbox.js: https://dl-web.dropbox.com/spa/pjlfdak1tmznswp/checkbox.js/public/index.html
checkbox.js: https://dl-web.dropbox.com/spa/pjlfdak1tmznswp/checkbox.js/public/index.html
Second, make sure that you're serving your HTML page using https://
. The Dropbox API server uses https, and IE <= 9 doesn't allow cross-domain requests from http pages to https servers.
其次,确保您使用https://
. Dropbox API 服务器使用 https,并且 IE <= 9 不允许从 http 页面到 https 服务器的跨域请求。
Third, you shouldn't need the token and tokenSecret parameters in the authorize
call.
第三,您不应该在authorize
调用中需要 token 和 tokenSecret 参数。
If you still get the JScript runtime error, can you please point to the line of code that causes it? Also, consider opening an issue on the dropbox.js GitHub page. This will get faster responses.
如果您仍然收到 JScript 运行时错误,请您指出导致该错误的代码行吗?另外,考虑在 dropbox.js GitHub 页面上打开一个问题。这将得到更快的响应。