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

    Problema sull'evento onload

    Buon pomeriggio, ho uno script, che gestisce l'entrata e/o l'uscita di un div.
    Vorrei che, come viene caricata la pagina, che lo contiene, questo div, non si vedesse e quindi nascosto, e non viceversa...

    Come posso fare?Ho provato a richiamare la funzione sull'onLoad del body, ma niente..
    Sapreste dirmi come ovviare?

    Questo è lo script:


    codice:
    <script type="text/javascript">
    		window.addEvent('domready', function(){
    			//-vertical
    			
    			var mySlide = new Fx.Slide('test');
    
    $('toggle').addEvent('click', function(e){
    				e = new Event(e);
    				mySlide.toggle();
    				e.stop();
    			});
    			
    			$('hide').addEvent('click', function(e){
    				e = new Event(e);
    				mySlide.hide();
    				e.stop();
    			});
    
    }); 
    	</script>
    	
    </head>
    
    <body>
    
    	<div id="test">
    		Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
    	</div>
    
    
    	<div style="position:relative;margin-top:-20px;text-align:center">toggle</div>
    <div id="demo">
    
    </div>
    Grazie mille a tutti....

  2. #2
    altro script, che credo sia quello che gestisce effettivamente gli eventi...
    codice:
    Fx.Slide = Fx.Base.extend({
    
    	options: {
    		mode: 'vertical'
    	},
    
    	initialize: function(el, options){
    		this.element = $(el);
    		this.wrapper = new Element('div', {'styles': $extend(this.element.getStyles('margin'), {'overflow': 'hidden'})}).injectAfter(this.element).adopt(this.element);
    		this.element.setStyle('margin', 0);
    		this.setOptions(options);
    		this.now = [];
    		this.parent(this.options);
    		this.open = false;
    		this.addEvent('onComplete', function(){
    			this.open = (this.now[0] === 1);
    		});
    		if (window.webkit419) this.addEvent('onComplete', function(){
    			if (this.open) this.element.remove().inject(this.wrapper);
    		});
    	},
    
    	setNow: function(){
    		for (var i = 0; i < 2; i++) this.now[i] = this.compute(this.from[i], this.to[i]);
    	},
    
    	vertical: function(){
    		this.margin = 'margin-top';
    		this.layout = 'height';
    		this.offset = this.element.offsetHeight;
    	},
    
    	horizontal: function(){
    		this.margin = 'margin-left';
    		this.layout = 'width';
    		this.offset = this.element.offsetWidth;
    	},
    
    	/*
    	Property: slideIn
    		Slides the elements in view horizontally or vertically.
    
    	Arguments:
    		mode - (optional, string) 'horizontal' or 'vertical'; defaults to options.mode.
    	*/
    
    	slideIn: function(mode){
    		this[mode || this.options.mode]();
    		return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [0, this.offset]);
    	},
    
    	/*
    	Property: slideOut
    		Sides the elements out of view horizontally or vertically.
    
    	Arguments:
    		mode - (optional, string) 'horizontal' or 'vertical'; defaults to options.mode.
    	*/
    
    	slideOut: function(mode){
    		this[mode || this.options.mode]();
    		return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [-this.offset, 0]);
    	},
    
    	/*
    	Property: hide
    		Hides the element without a transition.
    
    	Arguments:
    		mode - (optional, string) 'horizontal' or 'vertical'; defaults to options.mode.
    	*/
    
    	hide: function(mode){
    		this[mode || this.options.mode]();
    		this.open = true;
    		return this.set([-this.offset, 0]);
    		//return this.start([this.element.getStyle(this.margin).toInt(), this.wrapper.getStyle(this.layout).toInt()], [0, this.offset]);
    	},
    
    	/*
    	Property: show
    		Shows the element without a transition.
    
    	Arguments:
    		mode - (optional, string) 'horizontal' or 'vertical'; defaults to options.mode.
    	*/
    
    	show: function(mode){
    		this[mode || this.options.mode]();
    		this.open = false;
    		return this.set([0, this.offset]);
    	},
    
    	/*
    	Property: toggle
    		Slides in or Out the element, depending on its state
    
    	Arguments:
    		mode - (optional, string) 'horizontal' or 'vertical'; defaults to options.mode.
    
    	*/
    
    	toggle: function(mode){
    		if (this.wrapper.offsetHeight == 0 || this.wrapper.offsetWidth == 0) return this.slideIn(mode);
    		return this.slideOut(mode);
    	},
    
    	increase: function(){
    		this.element.setStyle(this.margin, this.now[0] + this.options.unit);
    		this.wrapper.setStyle(this.layout, this.now[1] + this.options.unit);
    	}
    
    });
    Ho provato a modificare, l'evento hide, ma, non c'è verso..
    Il div, al caricamento della pagina, è sempre sull'evento show.
    Vorrei che al caricamento della pagina prendesse l'evento HIDE...

    Grazie mille...

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.