Hi, I''m using Toggle.display to show or hide a div, on a anchor onclick event. I want the div hided when the page is displayed the first time. I''m not very good in js and I''ve used the body onload event to call Toggle the first time. <body onload="Toggle.display(''myDiv'')" but using a common layout for the controller I call Toggle even when there isn''t myDiv in the page.... and I''m feeling guilty! :-) Either if I define a layout just for myDiv''s page. Is there another function to use? Any suggestions? Thanks, Enrico -- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke
On 5/17/05, Enrico Teotti <agenteo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > I''m using Toggle.display to show or hide a div, on a anchor onclick event. > I want the div hided when the page is displayed the first time. I''m > not very good in js and I''ve used the body onload event to call Toggle > the first time. > Is there another function to use? Any suggestions?Use this: <div id="myDiv" style="display:none;"> This hides the div in CSS (and won''t wait for the body.onload event to fire). -- rick http://techno-weenie.net
Didn''t use the toggle function yet, but why you don''t use a style attribute in your div element to hide it. <div id="myDiv" style="display:none;"></div> Am Dienstag, den 17.05.2005, 15:13 +0200 schrieb Enrico Teotti:> Hi, > I''m using Toggle.display to show or hide a div, on a anchor onclick event. > I want the div hided when the page is displayed the first time. I''m > not very good in js and I''ve used the body onload event to call Toggle > the first time. > <body onload="Toggle.display(''myDiv'')" > but using a common layout for the controller I call Toggle even when > there isn''t myDiv in the page.... and I''m feeling guilty! :-) Either > if I define a layout just for myDiv''s page. > Is there another function to use? Any suggestions? > Thanks, > Enrico >-- Norman Timmler Holländische Reihe 31 22765 Hamburg +49 (0)40 / 43 25 10 80 mailto:norman-QkIQCVqxERM@public.gmane.org _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \
Using this inline way works, I''ve had tried adding: display:hide; and now using display:none; inside the css: div#myDiv{ border: 1px solid black; padding: 10px; background: #f9faec; position: absolute; display:none; z-index: 0; left: 500px; margin-top: 5px; } but the div is always hidden even when I click the link... Thanks for the help, Enrico -- "The only thing necessary for the triumph of evil is for good men to do nothing" Edmund Burke
Enrico Teotti wrote:> Using this inline way works, I''ve had tried adding: > display:hide; > and now using > display:none; > inside the css: > div#myDiv{ > border: 1px solid black; > padding: 10px; > background: #f9faec; > position: absolute; > display:none; > z-index: 0; > left: 500px; > margin-top: 5px; > } > > but the div is always hidden even when I click the link... > Thanks for the help, > Enrico >Unless I''m missing something, you should be calling Element.toggle(''mydiv''), not Toggle.display(''mydiv''). If you ONLY want to show the div, then Element.show(''mydiv'') Matt
> Unless I''m missing something, you should be calling > Element.toggle(''mydiv''), not Toggle.display(''mydiv''). If you ONLY want > to show the div, then Element.show(''mydiv'')You are correct, Element.toggle is the new one. Toggle.display is depreciated. If you want to keep this in CSS and want to toggle classes, I have an Element.Class.toggle that toggle''s a class name instead. Element.Class.toggle(''myDiv'', ''hide''); or Element.Class.toggle(''myDiv'', ''on'', ''off''); I submitted it as a patch, so I''m guessing it''ll be available in a future version. Here''s my prototype script: http://comiclog.com/javascripts/prototype.js -- rick http://techno-weenie.net