Current time: 03-16-2010, 02:26 AM Hello There, Guest! (LoginRegister)


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Javascript Help
07-11-2009, 03:47 AM (This post was last modified: 07-11-2009 03:50 AM by Infranight.)
Post: #1
Javascript Help
I have this following code:
Code:
<script type="text/javascript">
function toggleLayer( whichLayer )
{
  var elem, vis;
  if( document.getElementById )
    elem = document.getElementById( whichLayer );
  else if( document.all )
      elem = document.all[whichLayer];
  else if( document.layers )
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
</script>

It makes my sidebar disappear when a link is clicked, however, when, I my sidebar disappears, my forum is still the same width as it was with the sidebar there, leaving a lot of white space.
I wish to clear that white space by making the forum increase in width to (100%) when the sidebar is gone, so could I add another factor to the javascript?
So, other than making the display: none; turn into display: block;, can I also add width: 75%; to width: 100%; when clicked?
Something like IPB's over here:
http://forums.invisionpower.com/
One more thing, when the sidebar is there, it shows hide sidebar, when it's not, it still says hide sidebar.
Is there someway to make it say show sidebar afterwards? I have Yumi's PHP in Templates and Conditionals installed.
This is my code:
Code:
<a href="javascript:toggleLayer('f_h');" title="Hide Sidebar">
Hide Sidebar
</a>
I'd really appreciate it if you could help!

[Image: signature.png]
AF Marketplace | Zynge.net

PM me w/ your email to get invited to Lockerz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-11-2009, 04:30 AM
Post: #2
RE: Javascript Help
Looks like it is working to me. I click the x above the side bar and it disappears and the width of the main forum expands
Find all posts by this user
Quote this message in a reply
07-11-2009, 05:11 AM
Post: #3
RE: Javascript Help
Can i suggest you use Jquery? It would be easier, quicker and you could add some cool fade effects.

[Image: y9jcmj8]
[Image: 235Ap]
My plugins & themes.
The Fun Button! For Vista Sidebar & Windows 7 desktop gadgets.
Find all posts by this user
Quote this message in a reply
07-11-2009, 11:41 AM
Post: #4
RE: Javascript Help
@skywalker
Really? It's working? Are you using a fluid site?

@_Tim
Ok, I'll give it a try, but I've already tried the sliding effect with jquery.

[Image: signature.png]
AF Marketplace | Zynge.net

PM me w/ your email to get invited to Lockerz
Visit this user's website Find all posts by this user
Quote this message in a reply
07-11-2009, 01:03 PM
Post: #5
RE: Javascript Help
Try fade, it is usually pretty straight forward.

[Image: y9jcmj8]
[Image: 235Ap]
My plugins & themes.
The Fun Button! For Vista Sidebar & Windows 7 desktop gadgets.
Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: