谷歌视图在框架中,因为它将'X-Frame-Options'设置为'SAMEORIGIN'

use*_*575 13 javascript iframe

<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>
Run Code Online (Sandbox Code Playgroud)

在这段代码之后,我有下一个错误

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'.
Run Code Online (Sandbox Code Playgroud)

如果我订

<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>
Run Code Online (Sandbox Code Playgroud)

然后,一切都很好

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

谢谢

小智 7

我发现让Google文档查看器在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>
Run Code Online (Sandbox Code Playgroud)


And*_*uba 0

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