Archivlink: javarea.de Forum > JavaScript > Ticker - Problem mit DOCTYPE
Vollständigen Link anzeigen: javarea.de Forum > JavaScript > Ticker - Problem mit DOCTYPE

Pages: [1]

geschrieben von derSteffen am 29.08.2007 - 18:42
Hallo,

ich habe auf http://www.javarea.de den statischen Ticker gefunden (http://www.javarea.de/index.php3?op....amp;id=150).
Okay das mit dem statisch will ich gar nicht haben und somit habe ich das rausgenommen. Nun sieht mein Quelltext wie folgt aus:

<body onload="TickerInit()">
<style type="text/css">
body {margin:0px;}
#tickercont {position:absolute; top:0px; left:0px; width:100%; height:18px; overflow:hidden; visibility:hidden;}
#ticker {position:relative; left:2000px; height:18px; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold;}
#ticker a {color:#ffff99; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
#ticker a:hover{color:#ff0000; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
</style>
<script language="JavaScript1.2" type="text/javascript">
/************************************************************************
Script made by Martial Boissonneault © 2001 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*************************************************************************/
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var nWidth = 1000; // width of text; more text you have higher this number is.
var nSpeed = 2; // the speed of the ticker.
var nBgOff = "#426099"; // the background-color onmouseout.
var nBgOn = "#aabbdd"; // the background-color onmouseover.
var nCoOff = "#aabbdd"; // the font-color onmouseout.
var nCoOn = "#426099"; // the font-color onmouseover.

/* You don't have to edit below this line */

var nEnd = -nWidth;
var nLeft = nWidth;
var timerTt = null;
var timerSt = null;

function TickerTape(){
if(ie5) {
innerWidth = document.body.clientWidth;
}
if(ie5 || ns6) {
obj.style.backgroundColor = nBgOff;
obj.style.color = nCoOff;
tck.style.left = nLeft;
tck.style.width = nWidth;
nLeft = nLeft - nSpeed;
if( nLeft < nEnd ) {nLeft = innerWidth;}
timerTt=setTimeout('TickerTape()', 30);
}
}

function StopIt(){
clearTimeout(timerTt);
obj.style.backgroundColor = nBgOn
obj.style.color = nCoOn
}

function TickerInit(){
if(ie5 || ns6) {
tck = document.getElementById('ticker');
obj = document.getElementById('tickercont');
obj.style.visibility = "visible";
obj.onmouseover=StopIt;
obj.onmouseout=TickerTape;
TickerTape();
}
}
</script>

<div id="tickercont">
<div id="ticker">
javarea.de - eine der größten Javascriptseiten im Deutschen Raum +++++ Hier finden Sie Scripte, Applets, Tools uvm.
</div>
</div>


Funktioniert auch alles wunderbar :-)

ABER sobald ich daraus eine (X)HTML - Seite machen möchte, funktioniert es im Firefox nicht mehr (Opera und IE 7 klappen)! Grund ist der Doctype.

Kann mir jemand helfen, dass das auch mit dem Doctype im Firefox funktioniert (Habe die aktuelle Firefox Version 2.0.0.6)

So sieht der Quelltext meiner Seite mit dem Ticker aus:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
</head>
<body onload="TickerInit()">
<style type="text/css">
body {margin:0px;}
#tickercont {position:absolute; top:0px; left:0px; width:100%; height:18px; overflow:hidden; visibility:hidden;}
#ticker {position:relative; left:2000px; height:18px; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold;}
#ticker a {color:#ffff99; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
#ticker a:hover{color:#ff0000; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
</style>
<script language="JavaScript1.2" type="text/javascript">
/************************************************************************
Script made by Martial Boissonneault © 2001 http://getElementById.com/
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/ for more free scripts and tutorials.
*************************************************************************/
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var nWidth = 1000; // width of text; more text you have higher this number is.
var nSpeed = 2; // the speed of the ticker.
var nBgOff = "#426099"; // the background-color onmouseout.
var nBgOn = "#aabbdd"; // the background-color onmouseover.
var nCoOff = "#aabbdd"; // the font-color onmouseout.
var nCoOn = "#426099"; // the font-color onmouseover.

/* You don't have to edit below this line */

var nEnd = -nWidth;
var nLeft = nWidth;
var timerTt = null;
var timerSt = null;

function TickerTape(){
if(ie5) {
innerWidth = document.body.clientWidth;
}
if(ie5 || ns6) {
obj.style.backgroundColor = nBgOff;
obj.style.color = nCoOff;
tck.style.left = nLeft;
tck.style.width = nWidth;
nLeft = nLeft - nSpeed;
if( nLeft < nEnd ) {nLeft = innerWidth;}
timerTt=setTimeout('TickerTape()', 30);
}
}

function StopIt(){
clearTimeout(timerTt);
obj.style.backgroundColor = nBgOn
obj.style.color = nCoOn
}

function TickerInit(){
if(ie5 || ns6) {
tck = document.getElementById('ticker');
obj = document.getElementById('tickercont');
obj.style.visibility = "visible";
obj.onmouseover=StopIt;
obj.onmouseout=TickerTape;
TickerTape();
}
}
</script>

<div id="tickercont">
<div id="ticker">
javarea.de - eine der größten Javascriptseiten im Deutschen Raum +++++ Hier finden Sie Scripte, Applets, Tools uvm.
</div>
</div>
</body>
</html>


Vielen Dank schonmal


geschrieben von Micha am 29.08.2007 - 19:19
Hi,

welche Fehlermeldung?

Micha

geschrieben von derSteffen am 29.08.2007 - 20:53
Hallo,

also es gibt keine Fehlermeldung. Im IE 7 und im Opera kommt der Text von rechts in das Bild "gezogen/geschoben". Im Firefox passiert gar nichts, bis nach ca. 15 Sekunden mein Text plötzlich links in meiner Box erscheint. Aber dort steht er auch nur und bewegt sich nicht weiter. In den anderen Browsern kommt der Text von rechts nach links, verschwindet dann im linken Bildbereich und kommt nach einigen Sekunden dann wieder von links ins Bild. Ist echt komisch.

Danke

geschrieben von Micha am 30.08.2007 - 06:39
Hi,

als mein FF sagte:

HTML-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
Warnung: Fehler beim Verarbeiten des Wertes für Eigenschaft 'left'.  Deklaration ignoriert.
Quelldatei: Test.html
Zeile: 0
Warnung: Fehler beim Verarbeiten des Wertes für Eigenschaft 'width'.  Deklaration ignoriert.
Quelldatei: Test.html
Zeile: 0


daher weiß ich dann, das die Einheiten fehlen:
HTML-Quelltext
1: 
2: 
tck.style.left = nLeft+"px";
tck.style.width = nWidth+"px";


versuchs mal.

Micha

geschrieben von derSteffen am 30.08.2007 - 08:51
:-) Klasse, es hat funktioniert. Da freue ich mich aber sehr. Vielen, vielen Dank.

Hier nun der funktionierende Code:

HTML-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
10: 
11: 
12: 
13: 
14: 
15: 
16: 
17: 
18: 
19: 
20: 
21: 
22: 
23: 
24: 
25: 
26: 
27: 
28: 
29: 
30: 
31: 
32: 
33: 
34: 
35: 
36: 
37: 
38: 
39: 
40: 
41: 
42: 
43: 
44: 
45: 
46: 
47: 
48: 
49: 
50: 
51: 
52: 
53: 
54: 
55: 
56: 
57: 
58: 
59: 
60: 
61: 
62: 
63: 
64: 
65: 
66: 
67: 
68: 
69: 
70: 
71: 
72: 
73: 
74: 
75: 
76: 
77: 
78: 
79: 
80: 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de">
<head>
</head>
<body onload="TickerInit()">
<style type="text/css">
body {margin:0px;} 
#tickercont {position:absolute; top:0px; left:0px; width:100%; height:18px; overflow:hidden; visibility:hidden;}
#ticker {position:relative; left:2000px; height:18px; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold;}
#ticker a {color:#ffff99; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
#ticker a:hover{color:#ff0000; font-family:tahoma,arial,helvetica,sans-serif; font-size:14px; font-weight:bold; text-decoration:none;}
</style>
<script type="text/javascript">
/************************************************************************  
Script made by Martial Boissonneault © 2001 http://getElementById.com/ 
This script may be used and changed freely as long as this msg is intact
Visit http://getElementById.com/  for more free scripts and tutorials.
*************************************************************************/
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);

var nWidth = 1000;          // width of text; more text you have higher this number is.
var nSpeed = 2;            // the speed of the ticker.
var nBgOff = "#426099";    // the background-color onmouseout.
var nBgOn  = "#aabbdd";    // the background-color onmouseover.
var nCoOff = "#aabbdd";    // the font-color onmouseout.
var nCoOn  = "#426099";    // the font-color onmouseover.

/* You don't have to edit below this line */

var nEnd = -nWidth;  
var nLeft = nWidth;
var timerTt = null;
var timerSt = null;

function TickerTape(){
    if(ie5) {
        innerWidth = document.body.clientWidth;
}
    if(ie5 || ns6) {
        obj.style.backgroundColor = nBgOff;
	      obj.style.color = nCoOff;
        tck.style.left = nLeft;
        tck.style.width = nWidth;
        tck.style.left = nLeft+"px";
        tck.style.width = nWidth+"px";
        nLeft = nLeft - nSpeed;
        if( nLeft < nEnd ) {nLeft = innerWidth;}
        timerTt=setTimeout('TickerTape()', 30);
    }
}

function StopIt(){
        clearTimeout(timerTt);
        obj.style.backgroundColor = nBgOn
	      obj.style.color = nCoOn
}

function TickerInit(){
    if(ie5 || ns6) {
        tck = document.getElementById('ticker');
        obj = document.getElementById('tickercont');
        obj.style.visibility = "visible";
        obj.onmouseover=StopIt;
        obj.onmouseout=TickerTape;
        
        TickerTape();
    }
}
</script>

<div id="tickercont"> 
<div id="ticker">
javarea.de - eine der größten Javascriptseiten im Deutschen Raum   +++++    Hier finden Sie Scripte, Applets, Tools uvm.
</div>
</div>

</body>
</html>


Powered by: JBB v.2.0.4 Copyright ©2000-2006, www.javarea.de.