PDA

View Full Version : IFRAME scroller



agmoss
04-16-2005, 03:36 AM
I am looking for some ideas on how to get the scroller to reset to the top of the external document AND have the initialdelay work. Currently the script allows for the initial delay on the first run through only.

Thanks

jscheuer1
04-16-2005, 04:11 AM
.

That being said, the solution here, if I understand you, is to change this:
function scrollDiv(){
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top)<thelength*(-1))
dataobj.style.top="5px"
setTimeout("scrollDiv()",40)
}to this:
function scrollDiv(){
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top)<thelength*(-1)){
dataobj.style.top="5px"
setTimeout("scrollDiv()", initialdelay)
}
else
setTimeout("scrollDiv()",40)
}Enjoy!

agmoss
04-16-2005, 02:36 PM
Thanks....didn't seem to work so I likely have not explained well enough. Here's the link to the external.htm file where the script is found. I am looking to have the scroll delay (based on the initialdelay variable) EACH time it is going to scroll through.

http://www.dynamicdrive.com/dynamicindex2/external.htm

Thanks for your help.

jscheuer1
04-17-2005, 01:16 AM
Worked here. I'll paste in the whole file. It is set to 5 second initial delay. It will pause for 5 seconds before each run through.


<!-- External.htm source-->
<html>
<body>

<div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache">

<!-- ADD YOUR SCROLLER CONTENT INSIDE HERE -->

<b>What's Hot</b></p>
<p align="left"><strong><font face="Verdana"><small><a href="http://www.dynamicdrive.com/dynamicindex9/encrypter.htm" target="_top">Source
code encrypter</a>&nbsp;</small></font></strong><br>
<font face="Verdana" size="2">Scramble the source of any chunk of code using
this unique script.</font></p>
<p align="left"><strong><font face="Verdana"><small><a href="http://www.dynamicdrive.com/dynamicindex5/flashlink.htm" target="_top">Flashing
links</a>&nbsp;</small></font></strong><br>
<font face="Verdana"><small>Bring attention to special links, by making them
flash!</small></font></p>
<p align="left"><small><strong><font face="Verdana"><a href="http://www.dynamicdrive.com/dynamicindex13/roamcursor.htm" target="_top">Roaming
Cursor</a>&nbsp;</font></strong></small><br>
<small><font face="Verdana">Display a second, &quot;roaming&quot; cursor on your
page with this fun animation script.</font></small></p>
<p align="left"><font face="Verdana"><strong><a href="http://www.dynamicdrive.com/dynamicindex11/animatedtitle.htm" target="_top"><small>Animated
Document title</small></a><br>
</strong><small>Animate into view your document's title!</small></font>

<!-- END SCROLLER CONTENT -->

</div>

<script type="text/javascript">

/***********************************************
* IFRAME 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
***********************************************/

//Specify speed of scroll. Larger=faster (ie: 5)
var scrollspeed=cache=2

//Specify intial delay before scroller starts scrolling (in miliseconds):
var initialdelay=5000

function initializeScroller(){
dataobj=document.all? document.all.datacontainer : document.getElementById("datacontainer")
dataobj.style.top="5px"
setTimeout("getdataheight()", initialdelay)
}

function getdataheight(){
thelength=dataobj.offsetHeight
if (thelength==0)
setTimeout("getdataheight()",10)
else
scrollDiv()
}

function scrollDiv(){
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top)<thelength*(-1)){
dataobj.style.top="5px"
setTimeout("scrollDiv()", initialdelay)
}
else
setTimeout("scrollDiv()",40)
}

if (window.addEventListener)
window.addEventListener("load", initializeScroller, false)
else if (window.attachEvent)
window.attachEvent("onload", initializeScroller)
else
window.onload=initializeScroller

</script>

</body>
</html>

agmoss
04-17-2005, 04:27 PM
Got it....thanks!

spoonofmilk
03-30-2006, 10:52 PM
Hi! I'm not sure if this is the same problem as I am having, but what I am getting is the external file reloading once the scroller has come to the end of the file and what I would like to happen is for the file to just scroll back up again rather than just jumping back into position. Is this possible?

http://www.spoonofmilk.com/arcproduction/ is the place I am using the script

Thanks!

jscheuer1
03-31-2006, 03:34 AM
I think I see what you are after, the scroller jumps to the top but, you would rather it slide in from the bottom. To get that effect, you can change the top restart position (default of 5px) hard coded into the scrollDiv() function on the external page to be about the height of your iframe on the container page (looked like about 250px to me). In plain English, find this function on latest.html:


function scrollDiv(){
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top)<thelength*(-1))
dataobj.style.top="5px"
setTimeout("scrollDiv()",40)
}

Change it to this:


function scrollDiv(){
dataobj.style.top=parseInt(dataobj.style.top)-scrollspeed+"px"
if (parseInt(dataobj.style.top)<thelength*(-1))
dataobj.style.top="255px"
setTimeout("scrollDiv()",40)
}

spoonofmilk
04-01-2006, 11:27 AM
ahhh wicked! much thanks!