![]() |
Re: Html-Seite automatisch scrollen (JavaScript)
Zitat:
Zitat:
|
AW: Html-Seite automatisch scrollen (JavaScript)
Hey... bin neu hier und auf der Suche nach einem ähnlichen Code...
Kann es sein das der letzte Stand von diesem Code nicht mehr funktioniert ? Hab es mal getestet, in meinem Firefox Version 3.6 bewegt sich allerdings nichts... :cyclops: Und wie muss der Code aussehen, wenn ich eine HTML Seite von oben nach unten scrollen lassen will, dann wieder nach oben, von links nacht rechts und von rechts nach links ? Danke im Vorraus für jede Hilfe...:thumb: |
AW: Html-Seite automatisch scrollen (JavaScript)
Den benutze ich für Hoch/Runter für Anker:
Code:
Das kann man jetzt noch für Rechts/Links erweitern. Aber wie man hier sieht: Opera ist außen vor.
//var scrollSteps = 200
var scrollSteps = 50; var timer=""; function scrollWin(anchorID) { if (navigator.userAgent.indexOf("Opera") == -1){ // not Opera var s,d; var test1 = document.body.scrollHeight; var test2 = document.body.offsetHeight if (test1 > test2) // all but Explorer Mac { s = document.body.scrollWidth; d = document.body.scrollHeight; } else // Explorer Mac; { //would also work in Explorer 6 Strict, Mozilla and Safari s = document.body.offsetWidth; d = document.body.offsetHeight; } var a,b; if (self.innerHeight) // all except Explorer { a = self.innerWidth; b = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode { a = document.documentElement.clientWidth; b = document.documentElement.clientHeight; } else if (document.body) // other Explorers { a = document.body.clientWidth; b = document.body.clientHeight; } var y; if (self.pageYOffset) // all except Explorer { y = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict y = document.documentElement.scrollTop; } else if (document.body) // all other Explorers { y = document.body.scrollTop; } var id = anchorID.substring(anchorID.indexOf("#")+1,anchorID.length) clearTimeout(timer) if (y <= document.getElementById(id).offsetTop-scrollSteps) { // scroll down window.scrollBy(0,scrollSteps); timer=setTimeout("scrollWin('"+id+"')",10); if(y > (d-b)-scrollSteps){ clearTimeout(timer); y = d-b; } } else { if(y >= document.getElementById(id).offsetTop+scrollSteps) { // scroll up window.scrollBy(0,-scrollSteps) timer=setTimeout("scrollWin('"+id+"')",10) } else { // scroll the last bit (smaller than scrollSteps) window.scrollBy(0, document.getElementById(id).offsetTop- y); clearTimeout(timer) y = document.getElementById(id).offsetTop } } return false; } return true; } Bernhard ADD: a) Herzlich willkommen in der DP b) Auch wenn ich jetzt schon geantwortet habe: Lieber nen neuen Thread aufmachen. |
AW: Html-Seite automatisch scrollen (JavaScript)
Gibt da ein cooles jQuery Plugin für:
![]() |
AW: Html-Seite automatisch scrollen (JavaScript)
Wow... hier bekommst man ja richtig schnell geantwortet...
Also habe mir jetzt diese HTML Datei angelegt, aber wenn ich diese aufrufe, bewegt sich nichts :(
Code:
<html>
<body> <head> <script type="text/javascript"> //var scrollSteps = 200 var scrollSteps = 50; var timer=""; function scrollWin(anchorID) { if (navigator.userAgent.indexOf("Opera") == -1){ // not Opera var s,d; var test1 = document.body.scrollHeight; var test2 = document.body.offsetHeight if (test1 > test2) // all but Explorer Mac { s = document.body.scrollWidth; d = document.body.scrollHeight; } else // Explorer Mac; { //would also work in Explorer 6 Strict, Mozilla and Safari s = document.body.offsetWidth; d = document.body.offsetHeight; } var a,b; if (self.innerHeight) // all except Explorer { a = self.innerWidth; b = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode { a = document.documentElement.clientWidth; b = document.documentElement.clientHeight; } else if (document.body) // other Explorers { a = document.body.clientWidth; b = document.body.clientHeight; } var y; if (self.pageYOffset) // all except Explorer { y = self.pageYOffset; } else if (document.documentElement && document.documentElement.scrollTop) { // Explorer 6 Strict y = document.documentElement.scrollTop; } else if (document.body) // all other Explorers { y = document.body.scrollTop; } var id = anchorID.substring(anchorID.indexOf("#")+1,anchorID.length) clearTimeout(timer) if (y <= document.getElementById(id).offsetTop-scrollSteps) { // scroll down window.scrollBy(0,scrollSteps); timer=setTimeout("scrollWin('"+id+"')",10); if(y > (d-b)-scrollSteps){ clearTimeout(timer); y = d-b; } } else { if(y >= document.getElementById(id).offsetTop+scrollSteps) { // scroll up window.scrollBy(0,-scrollSteps) timer=setTimeout("scrollWin('"+id+"')",10) } else { // scroll the last bit (smaller than scrollSteps) window.scrollBy(0, document.getElementById(id).offsetTop- y); clearTimeout(timer) y = document.getElementById(id).offsetTop } } return false; } return true; } </script> </head> <div id="datacontainer" style="position:absolute;left:1px;top:10px;width:100%" onMouseover="scrollspeed=0" onMouseout="scrollspeed=cache"> <!-- SCROLLER CONTENT --> <td><iframe name="teset" id="test" scrolling="no" src="text.html" width="720" height="240" frameborder="0">Sorry, your browser doesn't support iframes.</iframe></td> <!-- SCROLLER CONTENT ENDE --> </div> </body> </html> |
AW: Html-Seite automatisch scrollen (JavaScript)
Da ich jetzt gerade ein Beispiel parat habe, verweise ich ganz einfach auf dieses. Und zwar gibts das
![]() Bernhard |
AW: Html-Seite automatisch scrollen (JavaScript)
Hm, mit dem beispiel kann ich leider nicht so viel anfangen.
Also ich hätte gerne das die Seite automatisch in dem Frame scrollt/rotiert... Am besten zuerst von oben nach unten und zurück und danach von Links nach rechts und wieder zurück. (das ganze kann auch zufällig sein) Danke im voraus! :roll: |
AW: Html-Seite automatisch scrollen (JavaScript)
Meinst Du
![]() |
AW: Html-Seite automatisch scrollen (JavaScript)
Jaa kann man so sagen, allerdings sollte das ganze automatisch verlaufen so wie dieses Beispiel hier:
![]() Ob man eine HTML Datei vom Server oder eine komplette Webseite rotieren lassen kann ist egal, kann man ja einstellen wie man will. |
AW: Html-Seite automatisch scrollen (JavaScript)
Hat keiner mehr eine Idee ???:pale:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:43 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz