Archivlink: javarea.de Forum > JavaScript > SideScrollMenue Problem
Vollständigen Link anzeigen: javarea.de Forum > JavaScript > SideScrollMenue Problem

Pages: [1]

geschrieben von sobi am 07.02.2006 - 20:01
Hi. Ich hab mal das o.g. Menue aus dhtml Central eingesetzt. Im IE funzt es einwandfrei, bloss in der anderen Browsern verrutscht der rechte SCROLL ARROW immer unter die Scrollleiste::

DEMO:: http://demo.sobers.de/demo/

Soweit ich es rausgefunden hab, wird von dem Script die Seitenbreite bei allen Browsern ausser IE nicht richtig ermittelt. Kann mir da vielleicht jemand helfen ?? Ich poste mal für Unerschrockene den JS-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: 
81: 
82: 
83: 
84: 
85: 
86: 
87: 
88: 
89: 
90: 
91: 
92: 
93: 
94: 
95: 
96: 
97: 
98: 
99: 
100: 
101: 
102: 
103: 
104: 
105: 
106: 
107: 
108: 
109: 
110: 
111: 
112: 
113: 
114: 
115: 
116: 
117: 
118: 
119: 
120: 
121: 
122: 
123: 
/**********************************************************************************
SideScrollMenu
*   Copyright (C) 2001 <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a>
*   This script was released at DHTMLCentral.com
*   Visit for more great scripts!
*   This may be used and changed freely as long as this msg is intact!
*   We will also appreciate any links you could give us.
*
*   Made by <a href="/dhtmlcentral/thomas_brattli.asp">Thomas Brattli</a>  and modified by Michael van Ouwerkerk
*********************************************************************************/

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=new lib_bwcheck()


/**************************************************************************
Variables to set.
***************************************************************************/
sLeft = 0         //The left placement of the menu
sTop = 91         //The top placement of the menu
sMenuheight = 30  //The height of the menu
sArrowwidth = 11  //Width of the arrows
sScrollspeed = 20 //Scroll speed: (in milliseconds, change this one and the next variable to change the speed)
sScrollPx = 8     //Pixels to scroll per timeout.
sScrollExtra = 15 //Extra speed to scroll onmousedown (pixels)

/**************************************************************************
Scrolling functions
***************************************************************************/
var tim = 0
var noScroll = true
function mLeft(){
	if (!noScroll && oMenu.x<sArrowwidth){
		oMenu.moveBy(sScrollPx,0)
		tim = setTimeout("mLeft()",sScrollspeed)
	}
}
function mRight(){
	if (!noScroll && oMenu.x>-(oMenu.scrollWidth-(pageWidth))-sArrowwidth){
		oMenu.moveBy(-sScrollPx,0)
		tim = setTimeout("mRight()",sScrollspeed)
	}
}
function noMove(){
	clearTimeout(tim);
	noScroll = true;
	sScrollPx = sScrollPxOriginal;
}
/**************************************************************************
Object part
***************************************************************************/
function makeObj(obj,nest,menu){
	nest = (!nest) ? "":'document.'+nest+'.';
	this.elm = bw.ns4?eval(nest+"document.layers." +obj):bw.ie4?document.all[obj]:document.getElementById(obj);
   	this.css = bw.ns4?this.elm:this.elm.style;
	this.scrollWidth = bw.ns4?this.css.document.width:this.elm.offsetWidth;
	this.x = bw.ns4?this.css.left:this.elm.offsetLeft;
	this.y = bw.ns4?this.css.top:this.elm.offsetTop;
	this.moveBy = b_moveBy;
	this.moveIt = b_moveIt;
	this.clipTo = b_clipTo;
	return this;
}
var px = bw.ns4||window.opera?"":"px";
function b_moveIt(x,y){
	if (x!=null){this.x=x; this.css.left=this.x+px;}
	if (y!=null){this.y=y; this.css.top=this.y+px;}
}
function b_moveBy(x,y){this.x=this.x+x; this.y=this.y+y; this.css.left=this.x+px; this.css.top=this.y+px;}
function b_clipTo(t,r,b,l){
	if(bw.ns4){this.css.clip.top=t; this.css.clip.right=r; this.css.clip.bottom=b; this.css.clip.left=l;}
	else this.css.clip="rect("+t+"px "+r+"px "+b+"px "+l+"px)";
}
/**************************************************************************
Object part end
***************************************************************************/

/**************************************************************************
Init function. Set the placements of the objects here.
***************************************************************************/
var sScrollPxOriginal = sScrollPx;
function sideInit(){
	//Width of the menu, Currently set to the width of the document.
	//If you want the menu to be 500px wide for instance, just
	//set the pageWidth=500 in stead.

	pageWidth = (bw.ns4 || bw.ns6 || window.opera)?innerWidth:document.body.clientWidth;
	
	//Making the objects...
	oBg = new makeObj('divBg')
	oMenu = new makeObj('divMenu','divBg',1)
	oArrowRight = new makeObj('divArrowRight','divBg')
	
	//Placing the menucontainer, the layer with links, and the right arrow.
	oBg.moveIt(sLeft,sTop) //Main div, holds all the other divs.
	oMenu.moveIt(sArrowwidth,null)
	oArrowRight.css.width = sArrowwidth;
	oArrowRight.moveIt(pageWidth-sArrowwidth,null)
	
	//Setting the width and the visible area of the links.
	if (!bw.ns4) oBg.css.overflow = "hidden";
	if (bw.ns6) oMenu.css.position = "relative";
	oBg.css.width = pageWidth+px;
	oBg.clipTo(0,pageWidth,sMenuheight,0)
	oBg.css.visibility = "visible";
}

//executing the init function on pageload if the browser is ok.
if (bw.bw) onload = sideInit;


Da meine JS Kenntnisse sehr gering sind, bitte ich besonders um Antworten für einen Laien. Ich bedanke mich schon mal

cu
Uli

geschrieben von weisnix am 07.02.2006 - 21:15
Irgendwo ist da noch was falsch?

Komm aber gerade nicht drauf. Vielleicht Hilft dir das schon mal weiter.


HTML-Quelltext
1: 
pageWidth = (bw.ns4 || bw.ns6 || window.opera)?innerWidth-(screen.width-innerWidth):document.body.clientWidth;


Die Fensterbreite wird minus der Differenz aus Fensterbreite und Bildschirmauflösung ermittelt.

geschrieben von sobi am 07.02.2006 - 22:57
Was mir wohl auffällt ist, dass das Script anscheinend mal für die älteren Browser geschrieben wurde. Muss man vielleicht die neuen (NS7, FF, Opera) noch irgendwie eintragen ???

geschrieben von sobi am 07.02.2006 - 23:22
@weisnix:: Danke, aber es läuft damit nicht

@Rene:: hast Du keinen Plan ??

geschrieben von weisnix am 08.02.2006 - 08:15
Ich hatte ja erwähnt, dass da was nicht stimmt.

Das Script ist in Ordnung, das funktioniert für sich allein.

Wenn du diese Tabelle entfernst oder die Höhe änderst, liegt das Menü nicht mehr unter der Scrolleiste

HTML-Quelltext
1: 
2: 
3: 
4: 
5: 
6: 
7: 
8: 
9: 
<!-- Headline -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
 <tr>
  <td height="50" class="gray" style="padding-left: 17px;"><font size="6"><b>YOUR HOMEPAGE TITLE</b></font></td>
  <td height="50" width="251" class="brown">&nbsp;</td>
  <td height="50" width="35" class="orange">&nbsp;</td>

 </tr>
</table>


Muss leider in die Berufsschule – aber vielleicht hilft es die ja schon ein wenig weiter.

geschrieben von sobi am 08.02.2006 - 10:24
wenn ich die höhe ändere verschwindet der scrollbalken, dann ist das menue natürlich ok. mit scrollbalken leider nicht.

ich hab das menue auch mal ohne die seite blanko getestet. da ist die macke auch drin, dass der rechte arrow unter den scrollbalken verschwindet.

zum funktionieren müsste von der bildschirmauflösung die scrollbalkenbreite abgezogen werden. kann es sein, dass das script die neuen browser nicht identifiziert ??? das fragt doch noch die 4er versionen etc. ab ??

schönen dank aber schon mal

cu
uli

geschrieben von sobi am 08.02.2006 - 14:06
den arrow rechts und links muss man sich leider jetzt mal denken.

geschrieben von weisnix am 08.02.2006 - 18:57
Das Original-Script macht das nicht, das habe ich gestern Abend schon ausprobiert.

Dann probier mal die Abfrage anders herum. Ich weis nur nicht ob der IE 5 damit klar kommt. Müsste aber.

HTML-Quelltext
1: 
pageWidth = (bw.ns4 || bw.ns6 || window.opera || bw.dom)? document.body.clientWidth : innerWidth;

geschrieben von sobi am 08.02.2006 - 19:26
D A N K E

läuft jetzt mit allen browsern. wie kommt man nur auf so was ?? vielleicht tauf ich das template jetzt in weiswas um

thnx a lot
cu
uli & manni der beagle
http://www.beagleboard.de

geschrieben von weisnix am 08.02.2006 - 20:30
Zitat
 Original geschrieben von sobi am 08.02.2006 - 19:26

läuft jetzt mit allen browsern. wie kommt man nur auf so was ??



Wenn man alles ausschließt was es nicht sein kann, bleibt meist nur eins übrig.

geschrieben von sobi am 08.02.2006 - 20:43

geschrieben von sobi am 10.02.2006 - 10:13
Hast Du eine Ahnung, warum im NS & FF nur 28 Links statt 30 dargestellt werden ??

cu
Uli

LINK:: http://free.templates.sobers.de/seventies/

geschrieben von weisnix am 10.02.2006 - 10:51
die brauchen mehr Platz!

#divBg {position:absolute; z-index:10; width:2800px;........

geschrieben von sobi am 10.02.2006 - 11:43
thnx
Uli



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