944,183 Members | Top Members by Rank

Ad:
Nov 11th, 2009
0

Spry tabs

Expand Post »
How to make something like spry tabs in dreamweaver with jquery or something. I don't have dreamweaver and i don't want to download a trial.
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
web3 is offline Offline
75 posts
since Oct 2009
Nov 14th, 2009
1
Re: Spry tabs
Hey.

Creating a simple "tabs" system using AJAX is easy enough. Especially if you use jQuery, or something equivalent.
You could just put the contents of all your tabs in separate HTML files, and use AJAX to load them into a <div> in your HTML.

For example, assuming the following structure:
text Syntax (Toggle Plain Text)
  1. root/
  2. index.html
  3. tabs.js
  4. styles.css
  5. tabs/
  6. tab1.html
  7. tab2.html
  8. tab3.html

You could simply do:
html Syntax (Toggle Plain Text)
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>AJAX Tabs Example</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  6. <link rel="Stylesheet" type="text/css" href="styles.css">
  7. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
  8. <script type="text/javascript" src="tabs.js"></script>
  9. </head>
  10. <body>
  11. <div id="TabContainer">
  12. <ul id="TabMenu">
  13. <li onclick="SwitchTab('tab1');">Tab 1</li>
  14. <li onclick="SwitchTab('tab2');">Tab 2</li>
  15. <li onclick="SwitchTab('tab3');">Tab 3</li>
  16. </ul>
  17. <div id="TabContents">Loading...</div>
  18. </div>
  19. </body>
  20. </html>
javascript Syntax (Toggle Plain Text)
  1. /**
  2.  * File: tabs.js
  3.  */
  4. $(document).ready(function()
  5. {
  6. // When the page loads, load the first tab.
  7. SwitchTab('tab1');
  8. });
  9. function SwitchTab(tabName)
  10. {
  11. // Put a Loading message in the TabContents div
  12. $('#TabContents').html('Loading...');
  13.  
  14. // Create the URL to the tab's HTML page.
  15. var url = 'tabs/' + tabName + ".html";
  16.  
  17. // Fire of an AJAX query to get the tab HTML
  18. $.get(url, null, function(data){
  19. // Change the contents of the TabContents div to the returned HTML
  20. $('#TabContents').html(data);
  21. }, 'html');
  22. }

And to make it pretty: (And I use that term very lightly)
css Syntax (Toggle Plain Text)
  1. /**
  2.  * File: styles.css
  3.  */
  4. root {
  5. display: block;
  6. font-size: 1.5em;
  7. font-family: Verdana, Arial, Sans;
  8. }
  9. #TabContainer {
  10. width: 550px;
  11. border: solid 1px #000000;
  12. margin: 15px auto;
  13. }
  14. #TabMenu {
  15. display: block;
  16. height: 25px;
  17. margin: 0;
  18. padding: 0;
  19. background-color: #bfbfbf;
  20. border-bottom: solid 1px #000000;
  21. }
  22. #TabMenu li {
  23. display: block;
  24. float: left;
  25. min-width: 50px;
  26. height: 25px;
  27. padding: 0 3px;
  28. background-color: #dfdfdf;
  29. border-right: solid 1px #333333;
  30. line-height: 25px;
  31. text-decoration: underline;
  32. cursor: pointer;
  33. }
  34. #TabMenu li:hover {
  35. background-color: #efefef;
  36. }
  37. #TabContents {
  38. clear: both;
  39. padding: 5px;
  40. }
Hope that helps.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: dhtml, element calling function that destroys element causes page reload, why?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: problem with pictures





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC