小编Lau*_*ont的帖子

当原点不同时从 iframe 获取 url

当用户通过单击 iframe 中的链接重定向时,我想从 iframe 获取 URL。iframe 的来源与 Web 应用程序不同。

例如:

<iframe src="startingUrl" class="embed-responsive-item" id="iframe" sandbox="" allowfullscreen</iframe>
Run Code Online (Sandbox Code Playgroud)

我在 iframe 上添加了一个加载侦听器,以检测用户何时重定向到此 iframe 中的其他 url:

const iframe = document.getElementById("iframe");

iframe.addEventListener("load", (evt) => {
    const location = iframe.contentWindow.location;

    console.log(location); // this gives me a Location object where I can see the href property
    console.log(location.href); // this gives me a SecurityError: Permission denied to get property "href" on cross-origin object, I also tried to get a copy of the object but that doesn't work either. …
Run Code Online (Sandbox Code Playgroud)

html javascript iframe same-origin-policy

5
推荐指数
1
解决办法
2432
查看次数

Google Drive API下载文件nodejs

我正在尝试使用node.js 中的Google Drive API v3 获取文件的内容。我在本文档中读到,我从中得到了一个流,drive.files.get({fileId, alt: 'media'})但事实并非如此。我得到了回报。

https://developers.google.com/drive/api/v3/manage-downloads

有人可以告诉我如何从该方法中获取流吗?

node.js google-drive-api

2
推荐指数
1
解决办法
1万
查看次数