开发者

Google News Box, Open News Page in New Window/Tab

开发者 https://www.devze.com 2023-03-24 14:34 出处:网络
I have attached a Google News Box on one of my pages. Right now, if the visitor click on the news, they will leave my site and go to the news site.

I have attached a Google News Box on one of my pages.

Right now, if the visitor click on the news, they will leave my site and go to the news site.

I'm wondering is it possible to insert target="_blank" somewhere so the news is loaded in new window/tab.

Note: the link is i开发者_开发知识库nside the google's iframe. so I was thinking if i can somehow to create the on-click event on-top of the google iframe while grab the it's 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>

Solution:

1: please refer to alfro's answer.

2: code below using the 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);
                        }


Find in documentation google.search.Search.LINK_TARGET_BLANK.

It's what you need. If you put your code would be easier to give an example.

EDITED

It's a little messy, but so does google here:

Page 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 (google):

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


Google abandoned "newsshow". It had been deprecated for a long time but a few weeks ago newsshow just stopped working. I had to scramble to build a replacement for my sites.

Here is a Google News RSS replacement that in many ways is better:

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

(BTW, links from the news stories are automatically opened in new tabs/windows.)

See this forum thread:

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

0

精彩评论

暂无评论...
验证码 换一张
取 消