
[英]How to disable pop-out option in pdf viewer with google drive embedded iframe
[英]How to disable pop-out option in pdf viewer with google doc iframe?
我正在使用以下代码使用带有 iframe 的 google 显示 pdf。它工作正常。 但我想禁用“弹出”选项(点击在带有谷歌文档的新标签中打开我的pdf)显示在我网页上放大选项旁边的右上角。 是否可以?
目前我正在使用以下代码 -
<iframe src="http://docs.google.com/gview?url=http://example.com/files/myfile.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
可以使用sandbox
来阻止在iframe
内工作的popup
<iframe
sandbox="allow-scripts allow-same-origin"
/>
allow-scripts
: 在 iframe 中运行 javascript。
allow-same-origin
: 允许从谷歌查看器加载文件。
没有allow-popups
,当用户点击pop-out
图标时什么也不会发生。
来源: https : //developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe
在您的页面上运行此 javascript(带有 jQuery 的示例)(我假设所有客户端的类都相同)
$('.ndfHFb-c4YZDc-Wrql6b').remove();
以下解决方案可用于删除预览按钮。 添加您的 iframe 的此代码 onload 功能。 它在 iframe 加载后应用。
var head = $("#iframe").contents().find("head");
var css = '<style type="text/css">' +
'.ndfHFb-c4YZDc-Wrql6b{display:none}; ' +
'</style>';
$(head).append(css);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.