Jul 4th, 2004, 11:00 AM
#1
Thread Starter
Addicted Member
Javascript Scroller Loop Help
I need help to make this script automatically loop and not stop after its done scrolling. Upon load, I want it to begin scrolling and right now it doesn't.
http://www.gdevresources.com/Pages/S...Scroller.shtml
Its the SINGLE SCROLLER demo
any help to make it loop upon start?
Jul 4th, 2004, 11:05 AM
#2
Frenzied Member
to make something happen upon start use the onLoad comand:
Code:
<body ... onLoad="doThis()">
Have I helped you? Please Rate my posts.
Jul 4th, 2004, 12:31 PM
#3
Thread Starter
Addicted Member
So im guessing it would be body onload=scrolldown() or whatever eh?
Jul 4th, 2004, 12:56 PM
#4
Frenzied Member
yep, but you should get used to having strings, not liternals. ie onload="scrolldown()" not onload=scrolldown()
that's a minor point though.
Another way is to simply put this in the code (not inside any function):
Code:
<script type="text/javascript">
scrolldown()
</script
This would have to be after the function has been declared and after any parts of the body that it uses have been created. if you're going to do it this way, then put that right at the end of the page. using the onload is better though.
Have I helped you? Please Rate my posts.
Jul 4th, 2004, 02:38 PM
#5
Thread Starter
Addicted Member
sweet...thanx, i'll let u know how it works out
Jul 4th, 2004, 02:50 PM
#6
Thread Starter
Addicted Member
Hmm, cant get it to work?
I basically took all their code and added html tags to it. Here check it out...
Code:
<html>
<head>
</head>
<body onload="scrolldown()">
<table width="155" cellpadding="0" cellspacing="1" border="1" bgcolor="#FFFFCC">
<tr>
<td width="20%" align="center" valign="bottom">
<a href="Javascript :scrolldown()"><font face="times" size="2"><b>Down</b></font></a>
</td>
<td width="20%" align="center" valign="bottom">
<a href="Javascript :scrollup()"><font face="times" size="2"><b>Up</b></font></a>
</td>
<td width="20%" align="center" valign="bottom">
<a href="Javascript :stopall()"><font face="times" size="2"><b>Stop</b></font></a>
</td>
<td width="20%" align="center" valign="bottom">
<a href="Javascript :shifttotop()"><font face="times" size="2"><b>Top</b></font></a>
</td>
<td width="20%" align="center" valign="bottom">
<a href="Javascript :selectspeed()"><font face="times" size="2"><b>Speed</b></font></a>
</td>
</tr>
</table>
<script language="JavaScript1.2">
iens6=document.all||document.getElementById
ns4=document.layers
<!-- Lower is faster -->
var scrollspeed = 40
<!-- Container setup -->
if (iens6){
document.write('<div id="container" style="position:relative;width:155;height:160px;overflow:hidden;border:2px ridge white">')
document.write('<div id="content" style="position:relative;width:155;left:0;top:0">')
}
</script>
<ilayer name="nscontainer" width=155 height=160 clip="0,0,155,160">
<layer name="nscontent" width=155 height=160>
<!--INSERT CONTENT HERE-->
<font type="times" size="2" style="color:black">
<b>Web Site Design</b><br><hr>
<table><tr>
<td valign="top">•</td><td>Hints about Web Site Design from some of the top <a href="http://builder.cnet.com/webbuilding/0-3881-8-5069140-1.html" target="_blank" onmouseover="stopall()"><font style="color:blue">guru"s</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Tag, Attribute, CSS, and Color reference <a href="http://builder.cnet.com/webbuilding/0-7530.html" target="_blank" onmouseover="stopall()"><font style="color:blue">charts</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Introduction to Web Site <a href="http://www.wdvl.com/Authoring/HTML/Tutorial/toc.html" target="_blank" onmouseover="stopall()"><font style="color:blue">Design</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Site <a href="http://www.wdvl.com/Location/Navigation/101/" target="_blank" onmouseover="stopall()"><font style="color:blue">Navigation</font></a>...</td></tr>
</table><br>
<b>HTML Tutorials</b><br><hr>
<table><tr>
<td valign="top">•</td><td>Introductory <a href="http://www.wdvl.com/Authoring/HTML/Intro/" target="_blank" onmouseover="stopall()"><font style="color:blue">HTML</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Beginning HTML Tutorial Listing <a href="http://www.pageresource.com/html/hclist.htm" target="_blank" onmouseover="stopall()"><font style="color:blue">many topics</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Advanced HTML Tutorial Listing <a href="http://www.pageresource.com/html/index6.htm" target="_blank" onmouseover="stopall()"><font style="color:blue">many topics</font></a>...</td></tr>
</table><br>
<b>Javascript Tutorials</b><br><hr>
<table><tr>
<td valign="top">•</td><td>Javascript and Browser Objects <a href="http://www.dannyg.com/javascript/quickref/index.html" target="_blank" onmouseover="stopall()"><font style="color:blue">Quick Reference</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Introductory <a href="http://www.webdeveloper.com/javascript/javascript_js_tutorial.html" target="_blank" onmouseover="stopall()"><font style="color:blue">Javascript</font></a>...</td></tr>
<tr><td valign="top">•</td><td><a href="http://www.webdeveloper.com/javascript/javascript_html_tnt_cookies.html" target="_blank" onmouseover="stopall()"><font style="color:blue">Javascript and Cookies</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Basic Javascript Tutorial Listing <a href="http://www.pageresource.com/jscript/index2.htm" target="_blank" onmouseover="stopall()"><font style="color:blue">many topics</font></a>...</td></tr>
<tr><td valign="top">•</td><td>Advanced Javascript Tutorial Listing <a href="http://www.pageresource.com/jscript/index6.htm" target="_blank" onmouseover="stopall()"><font style="color:blue">many topics</font></a>...</td></tr>
</table><br>
<b>DHTML Tutorials</b><br><hr>
<table><tr>
<td valign="top">•</td><td>Introductory <a href="http://www.wdvl.com/Authoring/DHTML/Intro/" target="_blank" onmouseover="stopall()"><font style="color:blue">DHTML</font></a>...</td></tr>
<tr><td valign="top">•</td><td><a href="http://www.pageresource.com/dhtml/indexcss.htm" target="_blank" onmouseover="stopall()"><font style="color:blue">Cascading Style Sheets</font></a>...</td></tr>
</table><br>
<b>Java Tutorials</b><br><hr>
<table><tr>
<td valign="top">•</td><td><a href="http://javaboutique.internet.com/tutorials/Thread0/" target="_blank" onmouseover="stopall()"><font style="color:blue">Java for Beginners</font></a>...</td></tr>
</table><br>
<b>Comprehensive Tutorials</b><br><hr>
<table><tr>
<td valign="top">•</td><td>A wide variety of Design, HTML, Java, and Javascript <br><a href="http://www.webdeveloper.com/tutorials.html" target="_blank" onmouseover="stopall()"><font style="color:blue">Tutorials</font></a>...</td></tr>
</table><br>
</font>
<!--END CONTENT-->
</layer></ilayer>
<script language="JavaScript1.2">
var step=1
if (iens6){
document.write('</div></div>')
var contentobj=document.getElementById? document.getElementById("content") : document.all.content
var contentheight=contentobj.offsetHeight
if (document.getElementById&&!document.all){
step=5
}
}
else if(ns4){
var contentobj=document.nscontainer.document.nscontent
var contentheight=contentobj.clip.height
}
<!-- speed select -->
function selectspeed() {
var speed = prompt("What speed would you like to scroll? slow (s), medium (m) or fast (f)?","")
if(speed=="s") {
step=1
}
if(speed=="m") {
step=3
}
if(speed=="f") {
step=5
}
}
function scrolldown() {
if(window.scrolltimerup){
clearTimeout(scrolltimerup)
}
if(iens6&&parseInt(contentobj.style.top)>=(contentheight*(-1))){
contentobj.style.top=parseInt(contentobj.style.top)-step
}else if(ns4&&contentobj.top>=(contentheight*(-1))){
contentobj.top-=step
}else{
if(iens6){
contentobj.style.top=160;
}else if(ns4){
contentobj.top=160;
}
}
scrolltimerdown = setTimeout("scrolldown()",scrollspeed)
}
<!-- scroll up function -->
function scrollup() {
if(window.scrolltimerdown){
clearTimeout(scrolltimerdown)
}
if(iens6&&parseInt(contentobj.style.top)<=0){
contentobj.style.top=parseInt(contentobj.style.top)+step
}else if(ns4&&contentobj.top<=0){
contentobj.top+=step
}
scrolltimerup = setTimeout("scrollup()",scrollspeed)
}
<!-- function to stop all scroll timers -->
function stopall() {
if(window.scrolltimerup){
clearTimeout(scrolltimerup)
}
if(window.scrolltimerdown){
clearTimeout(scrolltimerdown)
}
}
<!-- function that shifts the object to top -->
function shifttotop(){
stopall()
if (iens6) {
contentobj.style.top=0
}else{
contentobj.top=0
}
}
function getcontent_height(){
if (iens6)
contentheight=contentobj.offsetHeight
}
window.onload=getcontent_height
</script>
</body>
</html>
Jul 4th, 2004, 03:04 PM
#7
Frenzied Member
Hm.. I can't get it working either. I'm too busy to see how the thing actually works atm. maybe someone else can have a look.
Have I helped you? Please Rate my posts.
Jul 4th, 2004, 07:31 PM
#8
Thread Starter
Addicted Member
Ya hopefully, cuz I really need this
Jul 6th, 2004, 04:40 PM
#9
Thread Starter
Addicted Member
Ok well I figured that part out. However now -->
Everytime I click on Bold, Italic etc, in sentence 2 3 4 or whatever. The javascript command puts it in textarea 1 instead of 2 3 or 4.
How can I make it so that, if I click on Bold, Italic etc, the appropriate command will goto the appropriate textarea??
Code:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function View(form) {
msg=open("","DisplayWindow","status=1,scrollbars=1");
msg.document.write(form.Text2.value);
}
function Generate(form) {
var txt="<html><HEAD><TITLE>"+form.Name.value+"</TITLE></HEAD>\r\n";
txt+="</font></body></html>";
form.Text2.value=txt;
}
function AddText(form, Action){
var AddTxt="";
var txt="";
if(Action==4) {
txt=prompt("Text to be made BOLD.","Text");
if(txt!=null)
AddTxt="<b>"+txt+"</b>";
}
if(Action==5) {
txt=prompt("Text to be italicized","Text");
if(txt!=null)
AddTxt="<i>"+txt+"</i>";
}
if(Action==6) AddTxt="\r\n<p>";
if(Action==7) AddTxt="<BR>\r\n";
if(Action==8) AddTxt="<hr>\r\n";
if(Action==9) {
txt=prompt("URL for the link.","http://");
if(txt!=null){
AddTxt="<a href="+txt+">";
txt=prompt("Text to be show for the link","Text");
AddTxt+=txt+"</a>\r\n";
}
}
if(Action==10) {
txt=prompt("URL for graphic","URL");
if(txt!=null)
AddTxt="<img src="+txt+">\r\n";
}
if(Action==11) {
txt=prompt("Text to be made Underline.","Text");
if(txt!=null)
AddTxt="<u>"+txt+"</u>";
}
form.sent1.value+=AddTxt;
}
// End -->
</SCRIPT>
Code:
<table border='1' width='50%' align='left' cellspacing='1' cellpadding='3'>
<tr>
<td width='100' align='left'><b>$CONFIGURESENTENCE1</b></td>
<td width='240' colspan='2'>
<input type='button' value='Link' onClick='AddText(this.form,9);'>
<input type='button' value='Bold' onClick='AddText(this.form,4);'>
<input type='button' value='Italic' onClick='AddText(this.form,5);'>
<input type='button' value='Underline' onClick='AddText(this.form,11);'>
</td>
</tr>
<tr>
<td width='100' align='left'>$Sentence:</td>
<td width='160'>
<textarea name='sent1' rows='7' cols='33'>$sent1</textarea>
</td>
<td width='225'>$expsentence</td>
</tr>
<tr>
<td width='100' align='left'><b>$CONFIGURESENTENCE2</b></td>
<td width='240' colspan='2'>
<input type='button' value='Link' onClick='AddText(this.form,9);'>
<input type='button' value='Bold' onClick='AddText(this.form,4);'>
<input type='button' value='Italic' onClick='AddText(this.form,5);'>
<input type='button' value='Underline' onClick='AddText(this.form,11);'>
</td>
</tr>
Attached Images
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width