强制 iFrame 链接(在嵌入式 Google Doc 中)在新窗口中打开 [英] Force iFrame links (in embedded Google Doc) to open in new window

查看:43
本文介绍了强制 iFrame 链接(在嵌入式 Google Doc 中)在新窗口中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很奇怪,似乎无法将 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&amp;embedded=true"></iframe>

文档中的所有链接都将在 iFrame 中打开并通过 google 的重定向服务重定向:http://www.google.com/url?q=

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

推荐答案

好吧,由于缺乏更好的选择,我决定在将 Google Doc URL 卷曲并在将其加载到 iFrame 之前执行一些 jQuery 魔法.

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");

页面.html

$("#google_content").html("<iframe width='100%' height='600' frameborder='0' src='http://www.example.com/Curl/Curl.php'></iframe>");

Google,这真的是推荐的解决方法吗?;)

这篇关于强制 iFrame 链接(在嵌入式 Google Doc 中)在新窗口中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆