/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] scrollable area – script only works in IE

I have used a script by David G. Miles to insert a scrollable area onto a webpage. Everything works perfectly when I test it on an IE browser. I can’t get it to work with other browsers like Netscape or Firefox – the area just displays what can fit, it won’t scroll down. Can someone please advise me what I need to do to make this compatible with other browsers? I’ve included the original script exactly as I got it below – this will display correctly in an IE browser. Thanks!

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>
<html xmlns=”http://www.w3.org/1999/xhtml“>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8″ />
<title>Untitled Document</title>
<style type=”text/css”>

#divUpControl {position:absolute; left:150px;top:318px; width:320px;height:30px; z-index:1; text-align: right}
#divDownControl {position:absolute; left:150px; top:495px; width:320px;height:30px; z-index:1;text-align: right}
#divContainer {LEFT: 150px; VISIBILITY: hidden; OVERFLOW: hidden; WIDTH:320px; CLIP: rect(0px 320px 150px 0px); POSITION: absolute; TOP: 340px; HEIGHT: 150px}
#divContent {LEFT: 0px; POSITION: absolute; TOP: 0px}
h1 { font: bold 12px Arial, Helvetica, sans-serif}
body { font: normal 12px Arial, Helvetica, sans-serif}
pscoll { font: normal 12px Arial, Helvetica, sans-serif }
–>
</style>
<script language=”JavaScript”>
/* Extension written by David G. Miles ([url]http://www.z3roadster.net/dreamweaver/[/url])
based in part on code written by Thomas Brattli ([url]http://www.bratta.com)*
/[/url]
// Courtesy of SimplytheBest.net – [url]http://simplythebest.net/scripts/[/url]
<!–
function verifyCompatibleBrowser(){
this.ver=navigator.appVersion
this.dom=document.getElementById?1:0
this.ie5=(this.ver.indexOf(“MSIE 5”)>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom)?1:0;
this.ns5=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie5 || this.ie4 || this.ns4 || this.ns5)
return this
}
bw=new verifyCompatibleBrowser()

var speed=50
var loop, timer

function ConstructObject(obj,nest){
nest=(!nest) ? ”:’document.’+nest+’.’
this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+’document.’+obj):0;
this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+’document.’+obj):0;
this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
this.up=MoveAreaUp;this.down=MoveAreaDown;
this.MoveArea=MoveArea; this.x; this.y;
this.obj = obj + “Object”
eval(this.obj + “=this”)
return this
}
function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x
this.css.top=this.y
}
function MoveAreaDown(move){
if(this.y>-this.scrollHeight+objContainer.clipHeight){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+”.down(“+move+”)”,speed)
}
}
function MoveAreaUp(move){
if(this.y<0){
this.MoveArea(0,this.y-move)
if(loop) setTimeout(this.obj+”.up(“+move+”)”,speed)
}
}
function PerformScroll(speed){
if(initialised){
loop=true;
if(speed>0) objScroller.down(speed)
else objScroller.up(speed)
}
}
function CeaseScroll(){
loop=false
if(timer) clearTimeout(timer)
}
var initialised;
function InitialiseScrollableArea(){
objContainer=new ConstructObject(‘divContainer’)
objScroller=new ConstructObject(‘divContent’,’divContainer’)
objScroller.MoveArea(0,0)
objContainer.css.visibility=’visible’
initialised=true;

}

function displayStatusMsg(msgStr) {
status=msgStr;
document.returnValue = true;
}

function preloadImages() {
var d=document; if(d.images){ if(!d.p) d.p=new Array();
var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf(“#”)!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}

function swapImgRestore() {
var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function findObj(n, d) {
var p,i,x; if(!d) d=document; if((p=n.indexOf(“?”))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document); return x;
}

function swapImage() {
var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//–>
</script>
<script language=”JavaScript”>
<!–
function reloadPage(init) { //reloads the window if Nav4 resized
if (init==true) with (navigator) {if ((appName==”Netscape”)&&(parseInt(appVersion)==4)) {
document.pgW=innerWidth; document.pgH=innerHeight; onresize=reloadPage; }}
else if (innerWidth!=document.pgW || innerHeight!=document.pgH) location.reload();
}
reloadPage(true);
// –>
</script>

</head>

<body onLoad=”InitialiseScrollableArea();preloadImages(‘images/scroller_up_on.gif’,’images/scroller_down_on.gif’)”>

Hello

<!– begin scrollable area object –>
<div id=”divUpControl”> <a href=”javascript:;” onMouseOver=”PerformScroll(-7);displayStatusMsg(‘Scroll Up’);swapImage(‘scroller_up_button’,”,’images/scroller_up_on.gif’,1);return document.returnValue” onMouseOut=”CeaseScroll();swapImgRestore()”><img name=”scroller_up_button” src=”images/scroller_up.gif” border=”0″ alt=”Up”></a></div>
<div id=”divDownControl”> <a href=”javascript:;” onMouseOver=”PerformScroll(7);displayStatusMsg(‘Scroll Down’);swapImage(‘scroller_down_button’,”,’images/scroller_down_on.gif’,1);return document.returnValue” onMouseOut=”CeaseScroll();swapImgRestore()”><img name=”scroller_down_button” src=”images/scroller_down.gif” border=”0″ alt=”Down”></a></div>
<div id=”divContainer”>
<div id=”divContent”> <b>SimplytheBest.net</b>
<p class=”pscoll”>
<img src=”http://simplythebest.net/images/smallheadshare.gif” align=”left” vspace=”5″ hspace=”5″>As always,
the SimplytheBest <a href=”http://simplythebest.net/software/”>Shareware</a>
and <a href=”http://simplythebest.net/software/”>Freeware</a> directory. In the <a href=”http://simplythebest.net/software/”>New
page</a> you can find all the latest additions, while on the <a href=”http://simplythebest.net/software/”>Spotlight
page</a> you’ll find the Hot Picks of this moment.</p>
<p class=”pscoll”>
<img src=”http://simplythebest.net/images/smallheadinfo.gif” align=”left” vspace=”5″ hspace=”5″>Detailed
explanations on many Internet related subjects such as <a href=”http://info.simplythebest.net/”>spyware</a>,
<a href=”http://simplythebest.net/”>webmaster
resources</a>, selected links to related resources such as <a href=”http://info.simplythebest.net/”>Flash</a>,
<a href=”http://info.simplythebest.net/”>ASP</a>, <a href=”http://info.simplythebest.net/”>PERL</a>,
how-to pages such as <a href=”http://info.simplythebest.net/”>ColdFusion</a>,
<a href=”http://info.simplythebest.net/”>Servers</a>, and more.</p>
<p class=”pscoll”>
<img src=”http://simplythebest.net/images/smallheadmusic.gif” align=”left” vspace=”5″ hspace=”5″>
<a href=”http://simplythebest.net/music/”>Music directory</a> for
artists, manufacturers, record labels, studios, music sites and most industry
related sites. <a href=”http://simplythebest.net/music/”>Find</a>
a studio or <a href=”http://simplythebest.net/music/”>add</a>
your own listing and you just may be ‘discovered’.</p>
<p class=”pscoll”>
At SimplytheBest.net you’ll find also the Affiliate Programs directory, DHTML scripts and JavaScripts, the
Hosting directory and more.<br>
</p>
</div>
</div>
<!– end scrollable area object –>
</body>
</html>

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@FangApr 24.2008 — function MoveArea(x,y){
this.x=x;this.y=y
this.css.left=this.x[COLOR="SeaGreen"]+'px'[/COLOR];
this.css.top=this.y[COLOR="SeaGreen"]+'px'[/COLOR];
}
Copy linkTweet thisAlerts:
@BevisauthorApr 24.2008 — Thanks a million, that sorted it out. It's much appreciated!
×

Success!

Help @Bevis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...