View Full Version : rsspausescroller - open links in new window

05-04-2006, 08:40 PM
Script: rsspausescroller

Hi folks,

just wanted to inquire about a minor tweak: have links clicked in the scroller open new windows. I can't seem to figure this relatively simple thing out - would appreciate any tips.

05-05-2006, 04:02 AM
The issue here has nothing to do with the script, nor you.

You are trying to modify the content of the rss feed you are using.

If you're writing the feed yourself, awesome. If you're using plain text you wrote (this possible with this script? not sure), then you can also do it.

Basically, it's just displaying the data from an rss feed.

I don't know much about them, but I'm guessing they work the same way as html for links.

<a href="http://link.htm..." target="_blank">click me</a>

The target attribute will open a new ("blank") window.

The problem is that I'm assuming you can't access the feed itself, meaning you're stuck with whatever is in it.

Again, I don't know that much about rss, but I would assume you can't just display it in a way that would do things like make it all bold or make all the links open in a new window.
Might css work? (I'm assuming no, but at least this applies to all things on a page... but I wouldn't think that includes outside content.)

Aside from that... you could go an incredibly complex roundabout route taking the rss feed, running it through javascript (not php, etc. because it needs to be live) then displaying the result instead of the original rss feed.
The javascript would search the content for any <a> tags, and add a target="_blank" attribute to them. This would be nearly impossible to check, though, but, I suppose, since you just want that, you could set it to put, after the "a" "target="_blank"", and that would most likely work for all links (though some <a> tags are anchors, etc, not links, which might make those do weird things.
In the end, this is really advanced, and might not operate fast enough to work in a reasonable time with the feed.

Perhaps someone who is familiar with rss can be of more help.

05-05-2006, 04:34 AM
One way to gain control over links on your page that you cannot directly access for editing is to set the page's base target. Put a tag like so under the title and and meta tags (if any) near the top of the head section:

<title>My Page's Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<base target="_blank">

or (only if your document requires self closing tags for tags like <img> that do not usually have a closing tag):

<base target="_blank" />

Now all the links on the page will open in a new window. For other links on the page, like to other pages on your site, if you do not want them to open in a new window, you will have to set their targets individually:

<a href="page_on_my_site.htm" target="_self">Link Text or Image</a>

05-05-2006, 05:29 AM
Will the work for rss feeds? Do they not have their own formatting? (Never worked with rss myself, so I wouldn't know.)

05-05-2006, 05:45 AM
Will the work for rss feeds? Do they not have their own formatting? (Never worked with rss myself, so I wouldn't know.)

If you read the description for this script, you will see that the rss feed is first converted to a javascript array. From that point on, the only way it can appear on a page is as HTML of one sort or another, subject to the base element's settings, like any other HTML on the page.

05-05-2006, 05:47 AM
Oh, alright. That makes sense then. I didn't notice that.

05-05-2006, 06:12 AM
Looking over the script some more, there is a simpler way, where you use:

<script type="text/javascript">
//new rsspausescroller(RSS_id, divId, divClass, delay, linktarget, optionalswitch)
//1) RSS_id: "Array key of RSS feed in scrollerbridge.php script"
//2) divId: "ID of DIV to display ticker in. DIV is dynamically created"
//3) divClass: "Class name of this ticker, for styling purposes"
//4) delay: delay between message change, in milliseconds
//5) linktarget: Target of links inside RSS feed. Set to "" for current page.
//6) optionalswitch: "optional arbitrary" string to create additional logic for formatrssmessage() to use.
// By default, optionalswitch supports "date", or "date+description" to also show these parts of a RSS feed.

new rsspausescroller("dynamicdrive", "pscroller2", "rssclass", 3000, "_blank", "date+description")


add the _blank target parameter (in red above) as instructed in comment //5 (highlight green above).