问题描述
很奇怪,似乎没有办法在新窗口中打开Google文档链接。 (target =_ blank)。
Very oddly, there seems to be no way of setting Google Document links to open in a new window. (target="_blank").
在发布Google文档并使用嵌入功能时,会生成iframe代码段:
When publishing a Google Doc and using the embed functionality, an iframe snippet is generated:
<iframe src="https://docs.google.com/document/pub?id=1mfSz_3cWh6eW-X3EhQTtCoZ33Km131An8Kyvmuxi5oM&embedded=true"></iframe>
文档中的所有链接都将在iFrame中打开,并通过google的重定向服务重定向:
All links in the document will be opened within the iFrame and redirected via google's redirect service:http://www.google.com/url?q=
有没有办法,我可以在新窗口中打开这些链接?我知道可能有跨框架脚本问题,所以很奇怪Google没有简单的方法来实现这一点...
Is there any way I can make these links open in a new window? I know there might be cross-frame scripting issues so it's strange Google has no simple way of achieving this ...
推荐答案
OK ,在缺乏一个更好的选择我决定Curl的Google文档URL和做一些jQuery魔术之前加载到iFrame。
OK, in lack of a better alternative I decided to Curl the Google Doc URL and do some jQuery magic before loading it in an iFrame.
Curl.php
curl_setopt($ch, CURLOPT_URL, $Url);
[...]
$("#header").hide()
$("#footer").hide()
$('a[href^="http://"]').attr("target", "_blank");
Page.html
Page.html
$("#google_content").html("<iframe width='100%' height='600' frameborder='0' src='http://www.example.com/Curl/Curl.php'></iframe>");
Google,这是真的推荐的解决方法吗? ;)
Google, is this really the recommended workaround? ;)
这篇关于强制在新窗口中打开iFrame链接(在嵌入式Google文档中)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!