2011-08-03 130 views
1

我在其中一个页面上附加了Google News BoxGoogle新闻专栏,在新窗口中打开新闻页面/标签

现在,如果访问者点击新闻,他们将离开我的网站并前往新闻网站。

我想知道是否有可能在某处插入target="_blank",以便将新闻加载到新窗口/选项卡中。

注意:该链接位于谷歌的iframe中。所以我在想如果我能以某种方式在google iframe的顶部创建点击事件,同时抓住它的url。

<iframe frameborder=0 marginwidth=0 marginheight=0 border=0 
style="border:0;margin:0;width:928px;height:100px;" 
src="http://www.google.com/uds/modules/elements/newsshow/iframe.html? 
rsz=large&format=728x90&q=Internet%20Retailng%20Aus&element=true" scrolling="no" 
allowtransparency="true"></iframe> 

解决方案:

1:请参阅alfro的答案。

2:下面的代码使用api

google.load("elements", "1", {packages : ["newsshow"]}); 
     function onLoad() { 
      var options = { 
       "linkTarget" : "_blank"    
         } 
        var content = document.getElementById('news'); 
        var newsShow = new google.elements.NewsShow(content,options); 
         } 

回答

0

查找documentation google.search.Search.LINK_TARGET_BLANK。

这就是你需要的。如果你把你的代码更容易举个例子。

EDITED

这是一个有点乱,但这样做谷歌here

页答:

<head>...</head> 
<body style="font-family: Arial;border: 0 none;"> 
    <iframe height="90px" width="728px" frameborder="0" marginheight=0 marginwidth=0 scrolling="no" src="pageB.html"></iframe> 
</body> 

页B(谷歌):

<iframe height="90px" width="728px" frameborder="0" marginheight=0 marginwidth=0 scrolling="no" src="http://www.google.com/uds/modules/elements/newsshow/iframe.html?rsz=small&q=Foreclosure,Mortgage Refinance&format=728x90"></iframe> 
+0

你介意提供了一个例子来做到这一点通过API的方式,而不是到我使用的iframe(编辑问题) – Will

+0

在另一个iframe中调用谷歌iframe。像谷歌那样。 –

+0

非常感谢您的代码。我结束了与apis(编辑问题),因为它有一些额外的功能,我正在寻找,但你的答案几乎一样。 – Will

0

谷歌抛弃“ Google NewsShow使用”。它已被弃用很长一段时间,但几个星期前,newsshow停止工作。我不得不争先恐后地为我的网站建立一个替代品。

这是一个谷歌新闻的RSS替代品,在很多方面是更好的:(顺便说一句,从新闻报道的链接会自动在新标签/窗口中打开)

http://www.gooplusplus.com/news-frame-guide.html

见这个论坛主题:

http://hypercube.us/forum/index.php?topic=1501.0