webForumDet fria alternativet

Flytande länk

1 svar · 195 visningar · startad av Renault

RenaultMedlem sedan nov. 2001101 inlägg
#1

http://javascript.internet.com/page-details/floating-link.html

Jag har provat att lägga in detta javascript på en sida, och det fungerar ju bra. Men länken lägger sig på höger sida, hur gör jag för att lägga den till vänster eller helt enkelt där jag skriver koden, tex. left ,center eller liknande.

koden:

<!-- THREE STEPS TO INSTALL FLOATING LINK:

1. Copy the coding into the HEAD of your HTML document
2. Add the onLoad event handler into the BODY tag
3. Put the last coding into the BODY of your HTML document -->

<!-- STEP ONE: Paste this code into the HEAD of your HTML document -->

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function floatButton () {
if (document.all) {
document.all.topButton.style.pixelTop = document.body.scrollTop;
}
else if (document.layers) {
document.topButton.top = window.pageYOffset;
}
else if (document.getElementById) {
document.getElementById('topButton').style.top = window.pageYOffset + 'px';
}
}
if (document.all)
window.onscroll = floatButton;
else
setInterval ('floatButton()', 100);
function initButton () {
if (document.all) {
document.all.topButton.style.pixelLeft = document.body.clientWidth - document.all.topButton.offsetWidth;
document.all.topButton.style.visibility = 'visible';
}
else if (document.layers) {
document.topButton.left = window.innerWidth - document.topButton.clip.width - 15;
document.topButton.visibility = 'show';
}
else if (document.getElementById) {
document.getElementById('topButton').style.left = (window.innerWidth - 35) + 'px';
document.getElementById('topButton').style.visibility = 'visible';
}
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY onLoad="initButton()">

<!-- STEP THREE: Copy this code into the BODY of your HTML document -->

<SPAN ID="topButton" STYLE="position: absolute; visibility: hidden; top: 0px;">
<A HREF="javascript: window.scrollTo(0, 0); void 0" ONMOUSEOVER="window.status = 'top'; return true;" ONMOUSEOUT="window.status = ''; return true;">Back to Top</A>
</SPAN>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

JojoxxMedlem sedan juni 20004 306 inlägg
#2

I funktionen initButton() ställs positionen i x-led;

function initButton () { 
if (document.all) { 
document.all.topButton.style.pixelLeft = 10; 
document.all.topButton.style.visibility = 'visible'; 
} 
else if (document.layers) { 
document.topButton.left = 10; 
document.topButton.visibility = 'show'; 
} 
else if (document.getElementById) { 
document.getElementById('topButton').style.left = 10; 
document.getElementById('topButton').style.visibility = 'visible'; 
} 
}
129 ms totalt · 3 externa anrop · cache AV · v20260731051352-full.56cc9887
0 ms — hämta statistik (cache)
0 ms — hämta forumlista (cache)
126 ms — hämta tråd, inlägg och bilagor (db)