Google Views in a frame because it set 'X-Fram

2020-06-01 07:49发布

<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'.

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=false and have correct render without error?

Thanks

4条回答
Melony?
2楼-- · 2020-06-01 08:08

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

<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>
查看更多
Lonely孤独者°
3楼-- · 2020-06-01 08:10

First you should go to your document on google drive :

  1. click file
  2. publish to the web
  3. embed
  4. publish

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

查看更多
smile是对你的礼貌
4楼-- · 2020-06-01 08:31

Try this tutorial-

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=true should be in the 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>

查看更多
可以哭但决不认输i
5楼-- · 2020-06-01 08:32

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

查看更多
登录 后发表回答