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?
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?
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/
That takes care of the title link. But there's also a link in the description.
Thank you,
Bob
Add the red code (two places) as shown:
You have to scroll the code block to see all of the second addition.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() } } }
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
Thank you. That works great.
Bookmarks