
17-09-2007, 14:21
|
 |
|
|
חבר מתאריך: 02.10.05
הודעות: 2,355
|
|
|
בעיה ב- SetInterval כאשר קוראים לה מתוך המחלקה
עד עכשיו השתמשתי בפיתרון של fat-fish בשביל לעשות טקסט נגלל, אבל המחשב שלי התחיל לעשות צרות ונעלמה לי כמות יפה, כולל ספרייה לא קטנה של כל מיני דברים שעשיתי.. 
בגלל שלא מצאתי את הפיתרון שלו באינטרנט החלטתי לעשות זריז פיתרון דומה, זה מה שעשיתי עד עכשיו:
קוד:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Scroller</title>
<style type="text/css">
.sframe
{
overflow:hidden;
position:relative;
}
.scroller
{
position:absolute;
top: 0px;
}
</style>
<script language="JavaScript" type="text/javascript">
<!--
var d = document;
var divScroller = function(id, speed)
{
this.frame = d.getElementById(id);
this.scrolledDiv = this.frame.firstChild;
this.height = this.frame.style.height;
//--------------------------------------------
this.moveDiv = function()
{
if(this.scrolledDiv.style.top >= this.height)
this.scrolledDiv.style.top = (-this.scrolledDiv.offserHeight) + "px";
this.scrolledDiv.style.top = (parseInt(this.scrolledDiv.style.top) + 1) +"px";
}
this.handler = window.setInterval("this.moveDiv()", 500);
}
//-->
</script>
</head>
<body>
<div class="sframe" style="width: 200px; height: 200px;" id="scroll">
<div class="scroller">
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
Text text and a lot of text
</div>
</div>
<script type="text/javascript">
<!--
var marquue = new divScroller("scroll", 500);
//-->
</script>
</body>
</html>
בכל מקרה הדפדפן מוציא שגיאה:
קוד:
this.moveDiv is not a function
בשורה:
קוד:
this.handler = window.setInterval("this.moveDiv()", 500);
_____________________________________
|