Google新闻框,新窗口/标签中的新闻页面

时间:2011-08-03 01:07:02

标签: javascript html

我在其中一个页面上附加了Google News Box

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

我想知道是否可以在某处插入target="_blank",以便在新窗口/标签页中加载新闻。

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

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

2 个答案:

答案 0 :(得分:0)

documentation google.search.Search.LINK_TARGET_BLANK中查找。

这就是你所需要的。如果你把你的代码放在一个例子上会更容易。

EDITED

这有点混乱,但谷歌here也是如此:

第A页:

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

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

答案 1 :(得分:0)

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

以下是Google News RSS替代品,在许多方面更好:

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

(顺便说一句,来自新闻报道的链接会自动在新标签/窗口中打开。)

参见此论坛主题:

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