473,570 Members | 2,935 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 4708
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
1757
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,...
8
2960
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...
136
9251
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...
8
2437
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
2952
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
2606
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;...
1
1298
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....
5
1447
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...
5
1730
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
7948
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. ...
0
8150
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
5523
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5247
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...
0
3682
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...
0
3671
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2131
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
1
1238
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
971
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...

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.