/    Sign up×
Community /Pin to ProfileBookmark

scrolling Iframe with buttons PLZ HELP

here is a code that when the page loads the i frame will scroll up and down
can some one PLZ help me out i just need 2 functions one to scroll up/down w/ text buttons “javascript:scrollIframeDOWN()” “javascript:scrollIframeUP()”

it doesn’t even have to scroll just when you click on the button it will go up/down 20pix if that’s easier
thanks

[CODE]<HTML>
<HEAD>
<TITLE>
iframe scrolling
</TITLE>
<SCRIPT>
var step = 20;
var tid;
var oldPageYOffset;
function scrollIframe () {
if (window.anIframe && window.anIframe.scrollBy) {
var ifr = window.anIframe;
ifr.oldPageYOffset = ifr.pageYOffset;
ifr.scrollBy(0, step);
if (window.opera) {
if (ifr.pageYOffset == ifr.oldPageYOffset)
step = -step;
}
else if (document.all) {
if (ifr.document.body.scrollTop <= 0 ||
ifr.document.body.scrollHeight – ifr.document.body.scrollTop
<= ifr. document.body.offsetHeight)
step = -step;
}
else
if (document.getElementById) {
if (ifr.pageYOffset <= 0 ||
ifr.document.height – ifr.pageYOffset <= ifr.innerHeight)
step = -step;
}
}
}
</SCRIPT>
</HEAD>
<BODY ONLOAD=”tid = setInterval(‘scrollIframe()’, 100)”>
<IFRAME NAME=”anIframe” WIDTH=”780″ HEIGHT=”100″
SRC=”whatever.html”></IFRAME>
</BODY>
</HTML>[/CODE]

Thanks for your help

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@CrazyMerlinDec 10.2005 — just put invisible bookmark anchors in your page, make sure each has a different id tag, and use the document.getElementById('id of anchor').scrollIntoView(top)

this will scrollthe element to the top of the iframe

just be sure to keep a variable with the element index, so you always know where you are
×

Success!

Help @ww2airborne 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,
)...