Results 1 to 5 of 5

Thread: rss ticker question?

  1. #1
    Join Date
    Mar 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default rss ticker question?

    1) Script Title: Advanced RSS Ticker (Ajax invocation)

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...ajax/index.htm

    3) Describe problem: How can I edit the script to enable target="_blank" option?

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    rssticker_ajax.prototype.rotatemsg=function(){
    var instanceOfTicker=this
    if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
    setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
    else{ //else, construct item, show and rotate it!
    var tickerDiv=document.getElementById(this.tickerid)
    var linktitle='<div class="rsstitle"><a href="'+this.link[this.pointer]+'" target="_blank" >'+this.title[this.pointer]+'</a></div>'
    var description='<div class="rssdescription">'+this.description[this.pointer]+'</div>'
    var feeddate='<div class="rssdate">'+this.pubdate[this.pointer]+'</div>'
    if (this.logicswitch.indexOf("description")==-1) description=""
    if (this.logicswitch.indexOf("date")==-1) feeddate=""
    var tickercontent=linktitle+feeddate+description //STRING FOR FEED CONTENTS
    this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
    tickerDiv.innerHTML=tickercontent
    this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
    this.pointer=(this.pointer<this.feeditems.length-1)? this.pointer+1 : 0
    setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container every second
    }
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Mar 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That takes care of the title link. But there's also a link in the description.

    Thank you,
    Bob

  4. #4
    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

    Add the red code (two places) as shown:

    Code:
    // -------------------------------------------------------------------
    // initialize()- Initialize ticker method.
    // -Gets contents of RSS content and parse it using JavaScript DOM methods 
    // -------------------------------------------------------------------
    rssticker_ajax.prototype.hrefre = / href=/ig;
    rssticker_ajax.prototype.initialize=function(){ 
    if (this.ajaxobj.readyState == 4){ //if request of file completed
    if (this.ajaxobj.status==200){ //if request was successful
    var xmldata=this.ajaxobj.responseXML
    if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
    document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText
    return
    }
    var instanceOfTicker=this
    this.feeditems=xmldata.getElementsByTagName("item")
    //Cycle through RSS XML object and store each peice of an item inside a corresponding array
    for (var i=0; i<this.feeditems.length; i++){
    this.title[i]=this.feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue
    this.link[i]=this.feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue
    this.description[i]=this.feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue.replace(this.hrefre, ' target="_blank" href=');
    this.pubdate[i]=this.feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue
    }
    document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
    document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
    this.rotatemsg()
    }
    }
    }
    You have to scroll the code block to see all of the second addition.

    Or you can just replace the entire section indicated with the code in the code block above.
    Last edited by jscheuer1; 06-10-2012 at 05:15 PM. Reason: typo
    - John
    ________________________

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

  5. #5
    Join Date
    Mar 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you. That works great.

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
  •