/    Sign up×
Community /Pin to ProfileBookmark

Scrollable anchor top

I would like to know how I can scroll the top anchor
automatically like this: (see the scrolling top image @ right)

[url]http://www.silicon7.com/press_02.asp[/url]

It used div tag but do i need a separate
js for this? How did they do that?
Please help!

<div id=divMenu style=”top:303px; left:897px; visibility: visible; width: 22px; position: absolute; height: 31px;”>
<a href=”#top”><img src=”/img/icon_top.gif” width=”18″ height=”15″ border=”0″></a>
</div>

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@phpnoviceApr 04.2006 — Yes, it uses a JavaScript function (either driven by the window [b]onscroll[/b] event or on a [b]timer[/b]) to reposition the DIV to the approximately center of the height of the display area relative to the scrolled top of the document.
Copy linkTweet thisAlerts:
@webgirl7authorApr 04.2006 — thanks..

do you know where i can get a similar js?
Copy linkTweet thisAlerts:
@phpnoviceApr 04.2006 — You can get that one from that site.
Copy linkTweet thisAlerts:
@webgirl7authorApr 05.2006 — thanks.

can you point to that script from that site?
Copy linkTweet thisAlerts:
@phpnoviceApr 05.2006 — <SCRIPT language=JavaScript src="/java.js"></SCRIPT>
Copy linkTweet thisAlerts:
@webgirl7authorApr 05.2006 — yes. I'm looking for that script. Since it's using src

I cannot see that script from that site's source.

do you know where i can find the script that might be similar to

the one that they used?

thanks.
Copy linkTweet thisAlerts:
@phpnoviceApr 05.2006 — You just type it into the browser's address bar and the browser will download it for you.
Copy linkTweet thisAlerts:
@webgirl7authorApr 05.2006 — are you playing with me?

if you don't know how to write the code

just say so.
Copy linkTweet thisAlerts:
@rcracingfan24Apr 05.2006 — are you playing with me?

if you don't know how to write the code

just say so.[/QUOTE]


you can just type that url into your browser. The external script is at "/java.js" so type: "http://www.silicon7.com/[b]java.js[/b]". If your too lazy to do that, here is the entire contents of that JS file:

[CODE] var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);

function getRef(id) {
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}

var isNS = navigator.appName == "Netscape";
function moveRightEdge() {
var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck;
if (isNS4) {
yMenuFrom = divMenu.top;
yMenuTo = windows.pageYOffset +10; // À§ÂÊ À§Ä¡
} else if (isDOM) {
yMenuFrom = parseInt (divMenu.style.top, 10);
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) +340; // À§ÂÊ À§Ä¡
}
timeoutNextCheck = 500;
if (yMenuFrom != yMenuTo) {
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
if (yMenuTo < yMenuFrom)
yOffset = -yOffset;
if (isNS4)
divMenu.top += yOffset;
else if (isDOM)
divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
timeoutNextCheck = 10;
}
setTimeout ("moveRightEdge()", timeoutNextCheck);
}

if (isNS4) {
var divMenu = document["divMenu"];
divMenu.top = top.pageYOffset +10;
divMenu.visibility = "visible";
moveRightEdge();
} else if (isDOM) {
var divMenu = getRef('divMenu');
divMenu.style.top = (isNS ? window.pageYOffset : document.body.scrollTop) +10;
divMenu.style.visibility = "visible";
moveRightEdge();
}
[/CODE]
Copy linkTweet thisAlerts:
@phpnoviceApr 05.2006 — are you playing with me?

if you don't know how to write the code

just say so.[/QUOTE]

Grief! You're the testy sort. :rolleyes: If you don't understand a person's instructions, just say so and I'm sure they'd be happy to give you simpler ones. :p
×

Success!

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