2 Replies - 778 Views - Last Post: 17 May 2013 - 10:50 AM

#1 jin303  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-May 13

i am trying to create a news ticker but my code stop working

Posted 17 May 2013 - 10:25 AM

my code is shown below.can someone please point out my error?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

<link rel="stylesheet" type="text/css" href="jamcity.css" />


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function newsTicker()
{
	var $newsTicker=$('ul.news-ticker'),
		newsLength=0,
		windowWidth=$(window).width();
	$newsTicker.stop().removeAttr('style');
	
	$('.cloned-news').remove();
	
	$('ul.news-ticker>li').each(function(){newsLenth+=$(this).outerWidth();
	});
	
	if(newsLength>windowWidth){$('ul.news-ticker>li').clone().addClass('cloned-news').appendTo('ul.news-ticker').each(function(){
	newsLength+=$(this).outerWidth();
	});
	
	$newsTicker.css({'width':newsLength+'px'});
	function runTicker(){
	
	$newsTicker.animate({
	'left':'-'+(newsLength/2)+'px'
	}, newsLenght*14,'linear',function(){
	$newsTicker.css({'left':0+'px'}); runTicker();
	});
	}runTicker();
	
	$newsTicker.hover(function(){
	$(this).stop();
	},function(){
	runTicker();
	});
	} else{
	$newsTicker.unbind('mouseenter mouseleave');
	}
	
	/*$('pre').empty();
	$('pre').append('newsLength='+newsLength+'<br/>');
	$('pre').append('windoWidth='+windowWidth+'<br/>');*/
	
	}
	newsTicker();
	
	$(window).resize(function(){
	newsTicker();
	});
	
}</script>
<style>
div#banner{
height:250px;
width:300px;
background:blue;
background-image:url('http://www.greaterthan.org/embeds/apr2011/What_you_can_do_in_your_Community_300_x_250_static_Banner_Ad.jpg');
}
div#container{
height:20px;
width:300px;
margin:0;
background:red;
overflow:hidden;
position:relative;
}
ul.news-ticker{
color:white;
font:14px"Helvetica Neue",Arial,Helvetica,Geneva,san-serif;
overflow:hidden;
display:block;
position:absolute;
top:0;
width:100;
}
ul.news-ticker li{
float:lift;
display:block;
padding-right:20px;
margin:0;
}
ul.news-ticker li strong{
font-weight:bold;
}
.length-test{
height:10px;
width:10px;
position:absolute;
background:black;
left:0;
top:0;
z-index:10;
}
.cloned-news{background:pink;
}
</style>
</head>
<body>
<div id="banner">
<div id="container">
	
	<ul class="news-ticker">
		<li><strong>TRENDING</strong>add updates to your add from anywhere at any time</li>
		<li><strong>NEWS</strong>Advertise with us today</li>
		<li><strong>HEADLINES</strong>Mixing social media and online advertising to make the best of your budget</li>
		<li><strong>OTHER NEWS</strong>Thats all folks</li>
	</ul>
	
</div>
</div>
<table cellspacing="0" cellpadding="0" border="0">
<tr><td><a href="http://www.dailyalert.org" target="_blank">
<img border="0" SRC="http://www.jcpa.org/_images/daily_headlines.gif"
WIDTH="169" HEIGHT="20"></a></td></tr><tr><td>
<iframe id="hedlinesfrm" src="http://www.jcpa.org/Jcpa/VHeadlines.asp?width=200&height=70&bacgroundColor=FFFFFF&textColor=000000&delay=4000"
id="newsFlash" width="200px" height="200px" marginwidth="0"
marginheight="0" frameborder="0" scrolling="no"></iframe>
</td></tr></table>
</body>
</html>


Is This A Good Question/Topic? 0
  • +

Replies To: i am trying to create a news ticker but my code stop working

#2 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3252
  • View blog
  • Posts: 10,903
  • Joined: 12-December 12

Re: i am trying to create a news ticker but my code stop working

Posted 17 May 2013 - 10:45 AM

newsLenth is the first one. If you want assistance you will need to tell us what's happening. What does it do that it shouldn't do? What errors do you receive in the Console and what line(s) do they refer to in your posted code? Just posting all your code and saying "find my error for me" will not get you much of a response.

This post has been edited by andrewsw: 17 May 2013 - 10:45 AM

Was This Post Helpful? 1
  • +
  • -

#3 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3252
  • View blog
  • Posts: 10,903
  • Joined: 12-December 12

Re: i am trying to create a news ticker but my code stop working

Posted 17 May 2013 - 10:50 AM

..and newsLenght?!

Learn to use your browser's console - it will identify errors. There are links in my signature.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1