473,785 Members | 2,842 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Best Java Script Scroller

Hello,


Can somebody recommend me a Java Script scroller that can scroll an
i-frame ? I tried the Tigra scroller
(www.softcomplex.com/products/tigra_scroller/) but sometimes it does
not appear at all on my web page (www.mihaiu.name). It doesn't seem
to be reliable...
Any input is appreciated.

Regards,
Razvan

Aug 22 '05 #1
3 4719
Razvan <mi*****@mailci ty.com> wrote in message news:11******** **************@ g44g2000cwa.goo glegroups.com.. .
Hello,


Can somebody recommend me a Java Script scroller that can scroll an
i-frame ?


This is an update of a scroller I wrote long ago.
It will scroll any document, whether or not it's in an iframe.
I can't upload it to webspace currently, so here's the entire thing.

/**** SmartScroll (C)2000-05 Stephen Chalmers *************** ***

Provides CONTROLLABLE vertical auto scrolling of a document.
Best used to scroll frame windows containing long text passages.
Retains functionality of the vertical scroll bar, which additionally
is used to change scroll direction. Any horizontal offset is preserved.

Compatibility: NN4+ / Mozilla derivatives / IE4+ / Opera 5+

-- Installation --

Assuming the script is saved as smartscroll.js

<script type='text/javascript' src='smartscrol l.js'></script>

In the BODY tag, include: onload='SCstart Scroll()'

Optionally, set one or more user parameters thus:

<script type='text/javascript'>
SCdelay=130;
SCwrap=true;
SCmouseOver=fal se;
supportNN=true;
</script>

Their purpose is described below.

-- Setup --

To set the scroll speed, alter the value of 'SCdelay'. The higher the
value, the slower the scrolling. Default == 100.

There are two scroll modes, selected by setting the true/false state of 'SCwrap':

Alternate [false] - scroll direction changes at each end. (Default)

Wrap [true] - content scrolls upwards only, at bottom jumps back to top.

When using Wrap mode, to allow the text to disappear off the screen and re-appear
cleanly at the bottom, the page content should be padded with sufficient blank space,
top and bottom.

NOTE: Under Netscape 4.xx, if the page displays both scrollbars, scrolling may be erratic.
If this is likely to occur, set 'supportNN' to false.

-- Operation --

There are two control modes, selected by the true/false state of 'SCmouseover':

Mouseover [true] - Scrolling stops when the mouse is over the document and resumes
when it leaves.

Click [false] - Toggle scrolling ON/OFF by clicking anywhere on the page (or scrollbar
on Gecko browsers).
Toggle scroll direction with paired clicks anywhere on the page.

In both modes, change scroll direction by moving the scrollbar in the desired direction,
or with the up/down cursor keys (frame must have focus).
*** Do not edit below this line (unless you can't resist it) ***/

var SCpageY=0, SCxPoint=0, SCyPoint=0, SCup=-1, SCdn=1, SCdir=SCdn, SCmoved,
SCoffsetType=0, SColdY=-1, SCtravel=0, SCcount=-1, SCScrollEnable= true,
SCwait=1, SCpausedAt=0,

SCmouseOver=tru e,// - User variables -
SCdelay=100, // Alter these from script tags
SCwrap=false, // within the calling document.
supportNN=true; //
function SCgetPageX( idx )
{
var r=0;

switch(idx)
{
case 1 : r=window.pageXO ffset;break
case 2 : r=document.docu mentElement.scr ollLeft;break;
case 3 : r=document.body .scrollLeft;
}

return r;
}

function SCgetPageY( idx )
{
var r=0;

switch(idx)
{
case 1 : r=window.pageYO ffset;break
case 2 : r=document.docu mentElement.scr ollTop;break;
case 3 : r=document.body .scrollTop;
}

return r;
}

function SCSmartScroll()
{
SCnow=new Date();

if(SCScrollEnab le)
{
if(SCpausedAt) // paired-click detector
{
if(SCpausedAt+5 00 > SCnow.getTime() ) // compare current time with pause time
SCdir=-SCdir;
SCpausedAt=0;
}

SCxPoint=SCgetP ageX(SCoffsetTy pe);
// Read reported page position
SCyPoint=SCgetP ageY(SCoffsetTy pe);

if( (SCmoved=Math.a bs(SCtravel=(SC yPoint-SColdY))) >2 ) // Check for deviant movement
{ // caused by scrollbar use.
SCcount=-1;

if( (SCtravel<0 && SCdir==SCdn) || (SCtravel>0 && SCdir==SCup) )
SCdir=-SCdir;

SCpageY=SCyPoin t; // Update stored page position
}
else
if(SCmoved>0) // Check for movement..
SCcount=-1;
else
if(SCcount==-1) // on failure start counter
SCcount=SCwait;

if(SCcount==-1)
SColdY=SCyPoint ;
else // Wait period necessitated by NN, which intermittently
{ // delays reporting of correct Y position.

if(SCcount==0) // No movement after wait period,
if(SCwrap==true && SCdir>0) // wrap
SCpageY=0;
else
SCpageY=SColdY; // assume end reached and change direction

SCdir=-SCdir;
}

SCcount--;
}

window.scrollTo (SCxPoint, SCpageY+=SCdir) ; // move page
}
else
if(SCpausedAt== 0) // record time at pause
SCpausedAt=SCno w.getTime();

setTimeout("SCS martScroll()",S Cdelay);
}

function SCstartScroll()
{
SCoffsetType=(w indow.pageXOffs et!=null) ? 1
: ( document.compat Mode && document.compat Mode != 'BackCompat' ) ? 2
: ( document.body && typeof(document .body.scrollTop )!='undefined') ? 3
: 0;

if( document.layers )
if( supportNN==fals e )// Inhibit NN4 where selected.
SCoffsetType=0;
else
SCmouseOver=fal se;

if( SCoffsetType!=0 && window.scrollTo )
{
if(SCmouseOver)
if(window.Event && document.captur eEvents)
{
document.captur eEvents(Event.M OUSEOVER);
document.captur eEvents(Event.M OUSEOUT);
}
document.onmous eout=function() {SCScrollEnable =true;};
document.onmous eover=function( ){SCScrollEnabl e=false;};
}
else
{
if(window.Event && document.captur eEvents)
document.captur eEvents(Event.M OUSEUP);
document.onmous eup=function(){ SCScrollEnable^ =true;}
}

SCSmartScroll() ;
}
}


Aug 23 '05 #2
Hi Stephen,

Thanks a lot for your code.
Can I see somewhere the scroller in action ? How well is it tested
? I can test with the current version of Opera, Firefox, Netscape, IE
5.0 - IE5.5-IE6.0 but that may not be enough. For example if the
scripts works with Firefox 1.0.6 but breaks with Firefox 1.0.1 that is
not good. The same is true for other browsers. This is why I am saying
that proper testing must be done.
Can you help me to debug the script if necessary ? I am a
developer myself with some JavaScript experience but I do not have a
lot of time. If I can receive feed-back for you that could save days in
debug time - of course, if that is necessary.
Btw, the site where I want to put it is www.mihaiu.name. It
should replace the Tigra scroller that you can see on the upper left
side of the screen.
Regards,
Razvan

Aug 23 '05 #3
Razvan <mi*****@mailci ty.com> wrote in message news:11******** **************@ g43g2000cwa.goo glegroups.com.. .
Hi Stephen,

Thanks a lot for your code.
Can I see somewhere the scroller in action ? How well is it tested
? I can test with the current version of Opera, Firefox, Netscape, IE
5.0 - IE5.5-IE6.0 but that may not be enough. For example if the
scripts works with Firefox 1.0.6 but breaks with Firefox 1.0.1 that is
not good. The same is true for other browsers. This is why I am saying
that proper testing must be done.
Can you help me to debug the script if necessary ? I am a
developer myself with some JavaScript experience but I do not have a
lot of time. If I can receive feed-back for you that could save days in
debug time - of course, if that is necessary.
Btw, the site where I want to put it is www.mihaiu.name. It
should replace the Tigra scroller that you can see on the upper left
side of the screen.


I don't know how the Tigra scroller works, namely whether it is actually scrolling an iframe as you requested, or
something else.

The script is demonstrated at http://www.hotspot.freeserve.co.uk/ss/

The only issue I can find is with Safari on the Mac; the document's mouseout event either is not supported or does not
fire. This may have been fixed on later versions.

In five years I've never encountered a problem on Windows browsers, and I see no need to test it on every minor revision
of every browser.

Caveat auctor

--
Stephen Chalmers http://makeashorterlink.com/?H3E82245A

Aug 24 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1794
by: P Wolpert | last post by:
This is my first post. I hope I don't sound stupid. I have a script conflict when I put two scripts on one page. Both scripts will work if I use one at a time but the menu button script will not work when I add the scrolling text script. One script, the menu button script, has an "Onload" command and the other one does not. From what I know, and that's not much, I need to put both scripts in the "Onload" command. I just don't know how to...
8
2973
by: JA | last post by:
Hi, I have this JavaScript that is supposed to show random products from my database, and show something different every time you refresh or revisit. But I keep getting an error - on my computer - that says Syntax Error in Line 2. There is no error on most other computers, and the products show, but another script on the page, an article title scroller, stops - on most computers, but not all. It says "no articles available".
136
9457
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their code was littered with document.all and eval, for example, and I wanted to create a practical list of best practices that they could easily put to use. The above URL is version 1.0 (draft) that resulted. IMO, it is not a replacement for the FAQ,...
8
2446
by: Boni | last post by:
Dear all, imagine this is scroll bar. Min|-------------|scroller|---------|Max The position of scroller is set with Value. How do I change the width of scroller? Thank you in advance, Boni
2
2977
by: P2P | last post by:
Hi I am wondering if someone know of a free cross-browsers vertical scrolling script that - is cross cross-browsers - will call the scrolling content from an external html page or from a url page
14
2632
by: mistral | last post by:
Below is Typewriter Scroller script. I want adjust is as follows: remove lower dash "_" out; display text not in form, but inside div, without any borders (style="visibility:hidden"). Also I need control via css font size, color, family. How to adjust this? <script language="javascript" type="text/javascript"> <!-- begin var max=0; function textlist()
1
1312
by: CartmanCreative | last post by:
I am totally new to Java, and would desperately like some help. I have downloaded a Java Text Scroller that uses DHTML to scroll text up and down. There are other Java scrollers that do the same thing. My problem is that the Java always has code to place "fixed" or "static" text for scrolling. So I have to manually enter the words I need scrolled. Now . . I am also using a service called "FlexWindow" (www.flexwindow.com) where you can create...
5
1488
by: kidders | last post by:
Below is a script i need to modify to work and its driving me nuts. Essentially it fades the content of an array. The original script specified the object name, I tried to modify it to allow an object to be passed instead as there are two fading areas on the page code below, to be honest I could see absolutely no reason why but im not that offay with javascript so this could be down to me. Deadlines are getting tight on this one so not...
5
1740
by: devdoer | last post by:
HI: I have a page contain anthoer site's iframe window, but the iframe window ' document is large, so the scroller shows in the iframe window. I decide to caculate the iframe document's true size and set the iframe 's height and width according the document's true size , how can I do this? by scrollMaxY of the iframe ? Thanks.
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10327
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10092
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9950
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8973
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6740
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5381
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2879
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.