PDA

View Full Version : 100% Width for Memory Scroller



PZ5413
02-09-2008, 06:18 AM
1) Script Title: Memory Scroller

2) Script URL (on DD): http://dynamicdrive.com/dynamicindex2/memoryscroller.htm

3) Describe problem:
I currently have this set to 1000px, which works fine with users using a 1024x768 resolution, but falls a bit short for anyone using a larger res, such as myself, and I'm sure many of you. I tried setting the memory width equal to 100% but all that did was set it to 100px instead. Is there anyway to set this scroller to a 100% width?

Here is where it's being used... it's a ticker along the bottom of the page:
http://www.pzfantasyfootball.com

ddadmin
02-09-2008, 07:05 AM
Try changing the lines:


var combinedcssTable="width:"+(parseInt(memorywidth)+6)+"px;background-color:"+memorybgcolor+";padding:"+memorypadding+";"+borderCSS+";"
var combinedcss="width:"+memorywidth+";height:"+memoryheight+";"

to:


var combinedcssTable="width:100%;background-color:"+memorybgcolor+";padding:"+memorypadding+";"+borderCSS+";"
var combinedcss="width:100% ;height:"+memoryheight+";"

to get it to become 100% width wise.

PZ5413
02-09-2008, 07:32 AM
I don't see any difference between those two... I think they're exactly the same lol.

Didn't work btw. :-)

ddadmin
02-09-2008, 07:42 AM
Ops, going senile. Fixed. :)

PZ5413
02-09-2008, 08:06 AM
Awesome.. only a slight problem now, if ya check it out... the scroller stops once the end of the text completes... and thats it... lol. Also, it doesn't start at the beginning either. Would it be easier to implement a 100% scroll ticker type thing with the Cross Browser Marquee instead of the Memory Scroller?

Also, no prob with the senile thing... before I tried the same code you just gave me and it didn't work. I forgot that I put a wrap around it to center the 1000px scroller and the wrap was set to 1000px as well lol. I fixed that now and I'm stuck with the problem above.

PZ5413
02-09-2008, 06:28 PM
With ill attempts at getting any tickers to stretch 100%, I've decided to go with the ESPN Bottomline ticker for now.

If anyone can configure a way to get either the Memory Scroller or Cross Browser Marquee scripts to stretch 100% and still work properly that'd be great! Thanks!

ddadmin
02-09-2008, 07:09 PM
Actually, I don't get the problem with the scroller stopping once it's done with the 1st cycle. I do see the problem with the scroller not starting from the very beginning on subsequent cycles though.

The below modified script includes the original changes, plus the fix for the later problem mentioned above:


<script type="text/javascript">

/***********************************************
* Memory Scroller script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var memorywidth="100%"
var memoryheight="20px" //scroller height
var memorybgcolor="#DEFDD9" //scroller background
var memorypadding="2px" //padding applied to the scroller. 0 for non.
var borderCSS="border: 1px solid black;" //Border CSS, applied to scroller to give border.

var memoryspeed=2 //Scroller speed (larger is faster 1-10)
var pauseit=1 //Pause scroller onMousever (0=no. 1=yes)?

var persistlastviewedmsg=1 //should scroller's position persist after users navigate away (1=yes, 0=no)?
var persistmsgbehavior="onload" //set to "onload" or "onclick".

//Specify the scroller's content (don't delete <nobr> tag)
//Keep all content on ONE line, and backslash any single quotations (ie: that\'s great):

var memorycontent='<nobr><span style="font: bold 13px Verdana">Thank you for visiting <a href="http://www.dynamicdrive.com">Dynamic Drive.</a> If you find this script useful, please consider <a href="http://www.dynamicdrive.com/link.htm">linking to</a> or <a href="http://www.dynamicdrive.com/recommendit/">recommending</a> Dynamic Drive.</span></nobr>'


////NO NEED TO EDIT BELOW THIS LINE////////////
var combinedcssTable="width:100%;background-color:"+memorybgcolor+";padding:"+memorypadding+";"+borderCSS+";"
var combinedcss="width:100% ;height:"+memoryheight+";"

var divonclick=(persistlastviewedmsg && persistmsgbehavior=="onclick")? 'onClick="savelastmsg()" ' : ''
memoryspeed=(document.all)? memoryspeed : Math.max(1, memoryspeed-1) //slow speed down by 1 for NS
var copyspeed=memoryspeed
var pausespeed=(pauseit==0)? copyspeed: 0
var iedom=document.all||document.getElementById
if (iedom)
document.write('<span id="temp" style="visibility:hidden;position:absolute;top:-100px;left:-10000px">'+memorycontent+'</span>')
var actualwidth=''
var memoryscroller

if (window.addEventListener)
window.addEventListener("load", populatescroller, false)
else if (window.attachEvent)
window.attachEvent("onload", populatescroller)
else if (document.all || document.getElementById)
window.onload=populatescroller

function populatescroller(){
memoryscroller=document.getElementById? document.getElementById("memoryscroller") : document.all.memoryscroller
memoryscroller.style.left=parseInt(memorywidth)+8+"px"
if (persistlastviewedmsg && get_cookie("lastscrollerpos")!="")
revivelastmsg()
memoryscroller.innerHTML=memorycontent
actualwidth=document.all? temp.offsetWidth : document.getElementById("temp").offsetWidth
lefttime=setInterval("scrollmarquee()",20)
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function savelastmsg(){
document.cookie="lastscrollerpos="+memoryscroller.style.left
}

function revivelastmsg(){
lastscrollerpos=parseInt(get_cookie("lastscrollerpos"))
memoryscroller.style.left=parseInt(lastscrollerpos)+"px"
}

if (persistlastviewedmsg && persistmsgbehavior=="onload")
window.onunload=savelastmsg

function scrollmarquee(){
if (parseInt(memoryscroller.style.left)>(actualwidth*(-1)+8))
memoryscroller.style.left=parseInt(memoryscroller.style.left)-copyspeed+"px"
else
memoryscroller.style.left=document.getElementById('memorytable').offsetWidth+8+'px'
}

if (iedom){
with (document){
document.write('<table id="memorytable" border="0" cellspacing="0" cellpadding="0" style="'+combinedcssTable+'"><td>')
write('<div style="position:relative;overflow:hidden;'+combinedcss+'" onMouseover="copyspeed=pausespeed" onMouseout="copyspeed=memoryspeed">')
write('<div id="memoryscroller" style="position:absolute;left:0px;top:0px;" '+divonclick+'></div>')
write('</div>')
document.write('</td></table>')
}
}
</script>

PZ5413
02-09-2008, 07:23 PM
Awesome, it works perfectly. Thank you for all your help.