javascript 框架中的 Google 视图,因为它将“X-Frame-Options”设置为“SAMEORIGIN”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26079476/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 05:28:20  来源:igfitidea点击:

Google Views in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'

javascriptiframe

提问by user3006575

<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=false'  frameborder='0'></iframe>

after this code I have next error

在此代码之后我有下一个错误

Refused to display 'https://docs.google.com/a/myrussiaonline.ru/viewer?url=https://docs.google.…ormat%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=false' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.
Refused to display 'https://docs.google.com/a/myrussiaonline.ru/viewer?url=https://docs.google.…ormat%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=false' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'.

If I set

如果我设置

<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=true'  frameborder='0'></iframe>

Then, all fine

那么,一切都好

Can I set &embedded=falseand have correct render without error?

我可以设置&embedded=false并正确渲染而不会出错吗?

Thanks

谢谢

回答by mikeagoff

The only way I've found to get the Google Docs Viewer to work in an iframe is:

我发现让 Google Docs Viewer 在 iframe 中工作的唯一方法是:

<iframe src="https://docs.google.com/viewer?srcid=[YOUR_FILE'S_ID_HERE]&pid=explorer&efh=false&a=v&chrome=false&embedded=true" width="800" height="600" style="border: none;"></iframe>

回答by Abrar Jahin

Try this tutorial-

试试这个教程-

https://www.youtube.com/embed/A5SkbcId-v0

https://www.youtube.com/embed/A5SkbcId-v0

U should have your answer.

你应该有你的答案。

Update-

更新-

According to Google Policy, if u like to have your document viewed with a iFrame, then embedded=trueshould be in the URL.

根据 Google 政策,如果您希望使用 iFrame 查看您的文档,则embedded=true应该在URL 中

Demo Code-

演示代码-

<iframe src='https://docs.google.com/viewer?url=https://docs.google.com/document/d/125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE/export?format%3Dpdf&id=125CJmmlBfy7UgfYuBAmb1_HSCuyz8NV133361KTK1SE&embedded=true'  frameborder='0'></iframe>

回答by El Fadel Anas

First you should go to your document on google drive :

首先,您应该转到 google drive 上的文档:

  1. click file
  2. publish to the web
  3. embed
  4. publish
  1. 点击文件
  2. 发布到网络
  3. 嵌入
  4. 发布

You will get the code of the iframe you can use it to visualize your spreadsheet without the possibility to edit it

您将获得 iframe 的代码,您可以使用它来可视化您的电子表格,而无法对其进行编辑

回答by Andriy Kuba

No, you can not, this parameter is specify that source would be embedded. And the idea behind using it is to avoid clickHymaningattacks

不,您不能,此参数指定将嵌入源。使用它背后的想法是避免点击劫持攻击