Hi John,
I've looked closely at script positioning following your last post and have changed it around a bit. Still no good, though. Here's a copy of all the code, sent over four responses to comply with response length criteria. I'd be grateful for further comments.
Thanks,
Andrew
Code:
<!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=iso-8859-1" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>Untitled Document</title>
<!-- TemplateEndEditable --><!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<link href="../Mycascadingstylesheets.css" rel="stylesheet" type="text/css" />
<style type="text/css">
/*CSS for the scroller*/
#pscroller1{
width: 420px;
height: 65px;
border: 1px solid #0099FF;
padding: 5px;
background-color: #FFFFFF;
font-family:
Arial, Helvetica, sans-serif;
font-size: 12px;
color: #CC0000;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
text-decoration: none;)
</style>
<script type="text/javascript">
/*Message array for the scroller*/
var pausecontent=new Array()
pausecontent[0]='A delightful New Forest web site - Peter Roberts, Chairman of the New Forest Association'
pausecontent[1]='Since moving to the New Forest in 2008, I have made good use of what must be the*most informative*and useful web site on the New Forest - Paul Brock, writer, photographer and Scientific Associate of the Natural History Museum, London'
pausecontent[2]='Congratulations on a fantastic, comprehensive New Forest web site - Alan Gilbert'
pausecontent[3]='I think your New Forest web-site is fantastic, one of the best I have ever seen - Rob Anderson'
pausecontent[4]='I was just thinking about going to the New Forest and I found so much information - the walks, facts, things to do*and so much more. Thank you, you have made my life so much easier and have given me lots to think about - Celia Whitehouse'
pausecontent[5]='Love the site and have recommended it to many of my friends - Irene Button'
pausecontent[6]='Have just returned from a lovely weekend staying in Lyndhurst. Did two of your walks from the website - brilliant walks with excellent instructions. Really enjoyed them - Pat Beckley'
pausecontent[7]='I have been a visitor to your site for over a year and have watched it develop into probably the best online resource on the Forest - Nick, English Longbow Films'
pausecontent[8]='I just wanted to say thanks for your excellent walking routes from Brockenhurst and Boldre. We did both walks and the instructions were excellent. Many thanks - Dan Morgan'
pausecontent[9]='Congratulations on an excellent and informative site. It clearly represents a lot of careful work by one who cares for the Forest. Thank you - John Wingham'
pausecontent[10]='Firstly let me say what a fantastic web site. I have found it most useful in helping to plan a visit to the New Forest....Frank Farrow'
</script>
<script type="text/javascript">
/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 500)
}
// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------
pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}
// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------
pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 50)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}
// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------
pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}
pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}
// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------
pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
this.animateup()
}
}
Bookmarks