Delphi-PRAXiS
Seite 2 von 3     12 3      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Programmieren allgemein (https://www.delphipraxis.net/40-programmieren-allgemein/)
-   -   Html-Seite automatisch scrollen (JavaScript) (https://www.delphipraxis.net/140202-html-seite-automatisch-scrollen-javascript.html)

Woyzeck 7. Okt 2009 19:26

Re: Html-Seite automatisch scrollen (JavaScript)
 
Zitat:

Zitat von Lannes
Hallo,
Zitat:

Zitat von Woyzeck
...und es funktioniert jetzt auch... :)

dann wäre es doch prima wenn im letzten Beitrag dieses Topics der funktionierende Codezu finden wäre :roll:

gute Idee...

Zitat:

<script language='JavaScript' type='text/javascript'>
var Step = 1;
function lauf() {
var y = 0;
if (window.pageYOffset){
y=window.pageYOffset;
} else if (document.body && document.body.scrollTop){
y=document.body.scrollTop;
}
window.scrollBy(0, Step);
if (y == window.pageYOffset) {
window.setTimeout('window.scrollTo(0,0);lauf();',2 000);
}
else if (y==document.body.scrollTop) {
window.setTimeout('window.scrollTo(0,0);lauf();',2 000);
}
else{
window.setTimeout('lauf()', 50);
}
}
function start() {
window.setTimeout('lauf()', 50);
}
</script>
Nochmal vielen Dank an alle Helfer :thumb:

SilverXX 30. Mär 2011 14:42

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:

rollstuhlfahrer 30. Mär 2011 14:47

AW: Html-Seite automatisch scrollen (JavaScript)
 
Den benutze ich für Hoch/Runter für Anker:
Code:
//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;
}
Das kann man jetzt noch für Rechts/Links erweitern. Aber wie man hier sieht: Opera ist außen vor.

Bernhard

ADD:

a) Herzlich willkommen in der DP

b) Auch wenn ich jetzt schon geantwortet habe: Lieber nen neuen Thread aufmachen.

Phoenix 30. Mär 2011 14:48

AW: Html-Seite automatisch scrollen (JavaScript)
 
Gibt da ein cooles jQuery Plugin für: http://plugins.jquery.com/project/ScrollTo

SilverXX 30. Mär 2011 14:59

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>

rollstuhlfahrer 30. Mär 2011 16:36

AW: Html-Seite automatisch scrollen (JavaScript)
 
Da ich jetzt gerade ein Beispiel parat habe, verweise ich ganz einfach auf dieses. Und zwar gibts das hier.

Bernhard

SilverXX 30. Mär 2011 17:51

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:

Phoenix 31. Mär 2011 09:44

AW: Html-Seite automatisch scrollen (JavaScript)
 
Meinst Du sowas?

SilverXX 31. Mär 2011 13:39

AW: Html-Seite automatisch scrollen (JavaScript)
 
Jaa kann man so sagen, allerdings sollte das ganze automatisch verlaufen so wie dieses Beispiel hier: http://www.losegauner.de/inad.html

Ob man eine HTML Datei vom Server oder eine komplette Webseite rotieren lassen kann ist egal, kann man ja einstellen wie man will.

SilverXX 3. Apr 2011 12:30

AW: Html-Seite automatisch scrollen (JavaScript)
 
Hat keiner mehr eine Idee ???:pale:


Alle Zeitangaben in WEZ +1. Es ist jetzt 18:43 Uhr.
Seite 2 von 3     12 3      

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