 |
|
Author |
Message |
royhink
Joined: 19 Dec 2011
Posts: 3
|
Posted:
Mon Dec 19, 2011 3:35 pm |
  |
I want to have the links in the ItemDescription to open in a pop up or new window, and I'm having issues with the js. Any help greatly appreciated.
My template:
[code]
<TABLE WIDTH="100%">
~~~BeginItemsRecord~~~
<TR VALIGN="TOP">
<TD>
<BR>
<FONT SIZE="-1">~~~ItemPubDate~~~ </FONT>
<a href="javascript:popUp('~~~ItemLink~~~')"><b>~~~ItemTitle~~~</b></a>
<span class='rssFeed'>~~~ItemDescription~~~</span>
</TD>
</TR>
~~~EndItemsRecord~~~
</TABLE>
[/code]
I've got the following JS script activated onLoad. (The commented out code works, but it causes ALL links on my page to open in a new window. I just want what is within the span tag):
[code]
function RSSnewWindow() {
var frame = parent.document;
//var links = frame.getElementsByTagName('a');
var links = frame.getElementsByTagName('span').getElementsByTagName('a');
for (var i=0; i<links.length; ++i) {
links[i].setAttribute('target','_blank');
}
} [/code]
IDEALLY, I'd prefer it to open in a pop up, and I've got:
[/code]
function popUp(url) {
window.open(url, "", "height=700, width=1000px, resizable, scrollbars, status, location");
}
[code]
Any help greatly appreciated!
Thanks[/code] |
|
|
 |
 |
royhink
Joined: 19 Dec 2011
Posts: 3
|
Posted:
Mon Dec 19, 2011 6:25 pm |
  |
I've re-written the function to modify the href so that the link will open in a new pop up window.
[code] function RSSnewWindow() {
var frame = parent.document;
var links = frame.getElementsByTagName('a');
for (var i=0; i<links.length; ++i) {
if(links[i].href.indexOf("news.google.com") != -1) {
links[i].href = 'javascript:popUp(\''.concat(links[i].href,'\');')
}
}
}[/code]
This works only with rss from news.google.com. I'd prefer if it found all 'a' tags within a <div class=rssFeed, but
frame.getElementsByClass('rssFeed').getElementsByTagName('a');
doesn't work.
Any help greatly appreciated. |
|
|
 |
 |
|
| |