Results 1 to 7 of 7

Thread: rsspausescroller - open links in new window

  1. #1
    Join Date
    May 2006
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rsspausescroller - open links in new window

    Script: rsspausescroller
    http://www.dynamicdrive.com/dynamici...ller/index.htm

    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.

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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.

  3. #3
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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:

    HTML Code:
    <head>
    <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):

    HTML Code:
    <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:

    HTML Code:
    <a href="page_on_my_site.htm" target="_self">Link Text or Image</a>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  4. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

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

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Quote Originally Posted by djr33
    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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. #6
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Oh, alright. That makes sense then. I didn't notice that.

  7. #7
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looking over the script some more, there is a simpler way, where you use:

    Code:
    <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")
    
    </script>
    add the _blank target parameter (in red above) as instructed in comment //5 (highlight green above).
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •