Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    problemi con il resize dei div in mozilla

    Ciao a tutti,
    sono alle prime armi (o quasi) con javascript...ovvero ho creato il mio primo script interamente da solo (...almeno un "che bravo mi pare doveroso a questo punto ).
    Il problema è che funziona con internet explorer mentre con mozilla no...

    non so esattamente da cosa sia derivato il problema ma probabilmente è dovuto al fatto che mozilla non gestisce il ridimensionamento dei tag div...ovvero non posso impostare l'altezza dell'elemento.

    Il codice incriminato è questo (ho sottolineato in rosso le parti dove (credo) ci sia un errore:

    codice:
    <script language="JavaScript">
    
    function lib_bwcheck(){ 
    	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()
    
    var oMenu
    // Speed
    var speed = 10;
    // Number of menus
    var nummenu = 2;
    function ToggleMenu(num) {
    	if (oMenu[num].height == 0 || oMenu[num].action == "SlideUp")
    	{
    		oMenu[num].action = "SlideDown";
    		oMenu[num].slideDown();
    		oMenu[num].img.src = "arrowdown.gif";
    	}
    	else
    	{
    		if (oMenu[num].height == oMenu[num].maxheight || oMenu[num].action == "SlideDown")
    		{
    			oMenu[num].action = "SlideUp";
    			oMenu[num].slideUp();
    			oMenu[num].img.src = "arrowup.gif";
    		}
    	}	
    }
    
    function b_slideDown() {
    	if (this.action == "SlideDown") {
    		if (this.height < this.maxheight) 
    		{
    			this.height = this.height + 1;
    			this.css.height = this.height;
    			
    			if (this.parents!=null) {
    				for (a=0; a<this.parents.length;a++)
    				{
    					this.parents[a].height = this.parents[a].height + 1;
    					this.parents[a].maxheight = this.parents[a].maxheight + 1;
    					this.parents[a].css.height = this.parents[a].height;
    				}
    			}
    			setTimeout(this.obj+'.slideDown()', speed);
    		}
    		else
    		{
    			eval(this.css.height = this.maxheight);
    			this.action = "none";
    		}
    	}
    }
    function b_slideUp() {
    	if (this.action == "SlideUp") {
    		if (this.height > 0)
    		{
    			this.height = this.height - 1;
    			this.css.height = this.height;
    			if (this.parents!=null) {
    				for (a=0; a<this.parents.length;a++)
    				{
    					this.parents[a].height = this.parents[a].height - 1;
    					this.parents[a].maxheight = this.parents[a].maxheight - 1;
    					this.parents[a].css.height = this.parents[a].height;
    				}
    			}
    			setTimeout(this.obj+'.slideUp()', speed);
    		}
    		else
    		{
    			eval(this.css.height = 0);
    			this.action = "none";
    		}
    	}
    }
    
    function makeMenu(obj, nest, imm, parents) {
    	nest=(!nest) ? "":'document.'+nest+'.'
    	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
      	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
    	this.img=bw.dom?document.getElementById(imm):bw.ie4?document.all[imm]:bw.ns4?eval(nest+'document.'+imm):0;
    	this.action = "none"; 
    	this.height=0;
    	this.maxheight=bw.ns4?this.css.document.height:this.el.offsetHeight;
    	this.slideUp=b_slideUp; 
    	this.slideDown=b_slideDown;
        this.obj = obj + "Object"; 
    	this.parents = parents;	
    	eval(this.obj + "=this")
    	eval(this.css.height = 0);
    }
    
    function initmenu() {
    	var parents;
    	oMenu = new Array();
    	oMenu[0] = new makeMenu('menu1', '', 'menuimg1', parents);
    	
    		parents = new Array();
    		parents[0] = oMenu[0];
    		oMenu[1] = new makeMenu('menu1a1', '', 'menuimg1a1', parents);
    }
    </script>
    e potete vederlo operativo in http://www.wedding-in-venice.com/temp/indexframe.htm ...ovviamente funzionante solo in internet explorer.

    Dove sbaglio?

    Grazie.
    Ciao
    "I video giochi non influenzano i bambini. Voglio dire, se Pac-man avesse influenzato la nostra generazione, staremmo tutti saltando in sale scure, masticando pillole magiche e ascoltando musica elettronica ripetitiva!" (Kristian Wilson, Nintendo Inc., 1989)
    Pochi anni dopo naquero le feste rave, la musica techno e l'ecstasy...

    :quote:

  2. #2
    up
    "I video giochi non influenzano i bambini. Voglio dire, se Pac-man avesse influenzato la nostra generazione, staremmo tutti saltando in sale scure, masticando pillole magiche e ascoltando musica elettronica ripetitiva!" (Kristian Wilson, Nintendo Inc., 1989)
    Pochi anni dopo naquero le feste rave, la musica techno e l'ecstasy...

    :quote:

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.