/    Sign up×
Community /Pin to ProfileBookmark

Dynamic Ajax Content For News Bar

Hi,
I try to make an ajax script that can take the content from an HTML/PHP/TXT file and can show the content in a ticker/news bar.

I found webticker_lib.js very nice and basic for news bar. Also, I use jquery to update content.

My codes;

[CODE]<script type=”text/javascript” src=”prototype.js”></script>
<script type=”text/javascript” src=”jquery.js”></script>
<script>
jQuery.noConflict();
</script>
<DIV ID=”TICKER” STYLE=”display:none; border-top:1px solid #CCCCCC; border-bottom:1px solid #CCCCCC; overflow:hidden; background-color:#FFFFFF; width:620px” onmouseover=”TICKER_PAUSED=true” onmouseout=”TICKER_PAUSED=false”></DIV>
<script type=”text/javascript” src=”webticker_lib.js” language=”javascript”></script>
<script language=”javascript”>
function veriler(){
jQuery.get(“metin.html”,function(data){ jQuery(‘#TICKER’).html(data); });
}
window.setInterval(“veriler()”,100);
</script>
[/CODE]

And webticker_lib.js file;

[CODE]TICKER_CONTENT = document.getElementById(“TICKER”).innerHTML;

TICKER_RIGHTTOLEFT = false;
TICKER_SPEED = 2;
TICKER_STYLE = “font-family:Arial; font-size:12px; color:#444444”;
TICKER_PAUSED = false;

ticker_start();

function ticker_start() {
var tickerSupported = false;
TICKER_WIDTH = document.getElementById(“TICKER”).style.width;
var img = “<img src=ticker_space.gif width=”+TICKER_WIDTH+” height=0>”;

// Firefox
if (navigator.userAgent.indexOf(“Firefox”)!=-1 || navigator.userAgent.indexOf(“Safari”)!=-1) {
document.getElementById(“TICKER”).innerHTML = “<TABLE cellspacing=’0′ cellpadding=’0′ width=’100%’><TR><TD nowrap=’nowrap’>”+img+”<SPAN style='”+TICKER_STYLE+”‘ ID=’TICKER_BODY’ width=’100%’>&nbsp;</SPAN>”+img+”</TD></TR></TABLE>”;
tickerSupported = true;
}
// IE
if (navigator.userAgent.indexOf(“MSIE”)!=-1 && navigator.userAgent.indexOf(“Opera”)==-1) {
document.getElementById(“TICKER”).innerHTML = “<DIV nowrap=’nowrap’ style=’width:100%;’>”+img+”<SPAN style='”+TICKER_STYLE+”‘ ID=’TICKER_BODY’ width=’100%’></SPAN>”+img+”</DIV>”;
tickerSupported = true;
}
if(!tickerSupported) document.getElementById(“TICKER”).outerHTML = “”; else {
document.getElementById(“TICKER”).scrollLeft = TICKER_RIGHTTOLEFT ? document.getElementById(“TICKER”).scrollWidth – document.getElementById(“TICKER”).offsetWidth : 0;
document.getElementById(“TICKER_BODY”).innerHTML = TICKER_CONTENT;
document.getElementById(“TICKER”).style.display=”block”;
TICKER_tick();
}
}

function TICKER_tick() {
if(!TICKER_PAUSED) document.getElementById(“TICKER”).scrollLeft += TICKER_SPEED * (TICKER_RIGHTTOLEFT ? -1 : 1);
if(TICKER_RIGHTTOLEFT && document.getElementById(“TICKER”).scrollLeft <= 0) document.getElementById(“TICKER”).scrollLeft = document.getElementById(“TICKER”).scrollWidth – document.getElementById(“TICKER”).offsetWidth;
if(!TICKER_RIGHTTOLEFT && document.getElementById(“TICKER”).scrollLeft >= document.getElementById(“TICKER”).scrollWidth – document.getElementById(“TICKER”).offsetWidth) document.getElementById(“TICKER”).scrollLeft = 0;
window.setTimeout(“TICKER_tick()”, 30);
}
[/CODE]

However, in Firefox the text can change but it doesn’t stream. In IE7, both of them are not working! The text doesn’t change (although manually refresh) and doesn’t stream in IE7.

I cannot understand why working. What can be problem? How can I solve this? Thank you,

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@KuriyamaMar 27.2009 — The problem is the webticker_lib.js file. It's old and shouldn't be relied on.

why are you including both JQuery and Prototype? You must have a massive amount of JS download with both of these being included.

I recommend you just use JQuery or Prototype to write your own functionality. What you are describing isn't hard to do with those frameworks.
Copy linkTweet thisAlerts:
@manyakabiauthorMar 27.2009 — I am using Prototype for other scripts.

Also, I use JQuery to update content.

What is the wrong in webticker_lib.js?
×

Success!

Help @manyakabi spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...