PDA

View Full Version : manual IFrame scroller



DeadBoLt
03-10-2006, 07:25 PM
I'm trying to get this Scrollable content II @ http://www.dynamicdrive.com/dynamicindex11/scrollc2.htm script to work with content in an IFrame.

I want two seperate buttons (outside of the IFrame) to control the scrolling of the content within the IFrame.

Is there a way to do this?:confused:

Thanks
BoLt

Twey
03-10-2006, 07:58 PM
<input
type="button"
onclick="
document.frames['myIFrame'].moveup();
"
value="Move up"
/>
<input
type="button"
onclick="
document.frames['myIFrame'].movedown();
"
value="Move down"
/>
<input
type="button"
value="Stop"
onclick="
document.frames['myIFrame'].clearTimeout(document.frames['myIFrame'].moveupvar);
document.frames['myIFrame'].clearTimeout(document.frames['myIFrame'].movedownvar);
"
/>

DeadBoLt
03-10-2006, 09:39 PM
Thanks for the reply Twey. I've found a script that worked pretty well for this.

Here is what I did If anyone else has the same question.


<script type="text/javascript">
<!--
scrollPos = 0
speed=1
scrollMe=""

function scrollDown() {
clearTimeout(scrollMe)
scrollPos +=speed
window.frames["frame1_name"].scrollTo(0,scrollPos)
scrollMe=setTimeout("scrollDown()",50)

if(scrollPos>window.frames["frame1_name"].document.body.scrollHeight - (parseInt(document.getElementById("frame1_id").style.height)-10)){

scrollPos=window.frames["frame1_name"].document.body.scrollHeight - (parseInt(document.getElementById("frame1_id").style.height)-10)

clearTimeout(scrollMe)

}

}

function scrollUp() {
clearTimeout(scrollMe)
scrollPos -=speed
window.frames["frame1_name"].scrollTo(0,scrollPos)
scrollMe=setTimeout("scrollUp()",50)

if(scrollPos<speed){
scrollPos=0
clearTimeout(scrollMe)
}

}

function stopMe(){
clearTimeout(scrollMe)
}

// -->
</script>

<iframe name="frame1_name" id="frame1_id" src="page1.htm" scrolling="no" frameborder="yes" style="height:100px"></iframe><BR> <a href="#null" onmouseover="scrollUp()" onmousedown="scrollUp(speed=5)" onmouseup="scrollUp(speed=1)" onmouseout="stopMe()">Up</a> <a href="#null" onmouseover="scrollDown()" onmousedown="scrollDown(speed=5)" onmouseup="scrollDown(speed=1)" onmouseout="stopMe()">Down</a>

I've just replaced the (Up,Down) text with an image tag. Works like a charm. Hope this helps someone.

BoLt

alexan
05-22-2006, 01:54 AM
hi there,

Wow that really a nice script!!!:)

I have one question though.

Is it possible to get the scrolling smoother if the speed is set to a higher degree?

hope u have some ideas

greetings
alexan