2011-08-03 128 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