www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Rate Thread Display Modes
      #1  
    Old 10-30-2004, 02:58 PM
    laythss laythss is offline
    Registered User
     
    Join Date: Oct 2004
    Posts: 2
    Angry Changing text color or css style

    hello all, I hope I can get help here. I am newbie in java script and I am trying to do the following:
    I have a navigation bar on my website (made of link text, the color of the text is defined by a css style, in any case the text is white when the page loads and is red when it gets rolled over) What I want is when a vistor for example presses the "machine" button and gets directed to the page "machine.asp" which displays the same navigaton, I want the text for the link "machine" on my navigation to change to red for example and stay that way, that way the visitor will know what page s/he is on.
    structure of website:
    Each page (home.asp, machine.asp, ingredients.asp, etc.) includes a header called (head.asp) and a footer (foot.asp)
    http://www.always-coffee.com/web2/index.asp

    What I did:
    I added the following javascript in head.asp:

    <!-- Original: Kevin Lynn Brown Modefied by Layth-->

    <!-- Begin
    var path = "";
    var nav = "";


    var href = document.location.href;
    var s = href.split("/");
    for (var i=2;i<(s.length-1);i++) {
    }
    i=s.length-1;
    path+=s[i];

    if (path == "always-coffee-office-solution_main.asp"){

    nav="main";

    var nav ="";
    }

    // End -->

    Now here is my problems (or what I think My problems is):

    2- now if I get the first part right, then I can add more if statments to include all websites for the navigation part. BUT my biggest problem, is how do I get the text change color if the value of the variable nav="main" for example. AND where do I place that code in my document. PLEASE HELP. and I thank you in advance.
    Layth
    Reply With Quote
      #2  
    Old 10-30-2004, 03:35 PM
    Charles's Avatar
    Charles Charles is offline
    JavaScript Banned
     
    Join Date: Nov 2002
    Location: Baltimore, Maryland
    Posts: 11,881
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="Content-Script-Type" content="text/javascript">
    <meta name="Content-Style-Type" content="text/css">
    <title>Example</title>

    <style type="text/css">
    <!--
    a.current {background-color:#a00; color:#fff}
    -->
    </style>

    <script type="text/javascript">
    <!--
    onload = function () {
    var l, i = 0;
    while (l = document.links[i++]) {if (l.href == location) l.className = 'current'}
    }
    // -->
    </script>

    </head>
    <body>
    <ul>
    <li><a href="test.html">Test</a></li>
    <li><a href="http://www.w3.org/">W3C</a></li>
    </ul>
    </body>
    </html>
    __________________
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web
    Reply With Quote
      #3  
    Old 10-30-2004, 07:29 PM
    laythss laythss is offline
    Registered User
     
    Join Date: Oct 2004
    Posts: 2
    So how does it work

    I am not sure how that code works but I tried it out and it works as the example but how do I add it to my links at my nav, my code right now for these buttons is:

    <table cellpadding="0" cellspacing="0" border="0" width="1020">
    <tr bgcolor="#66CC00">

    <td width="196" align="center" bgcolor="#66CC00" class="backnavgray"><span class="nav"><a href="index.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Home</a></span></td>
    <td width="54" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_machine.asp" class="nav style7" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Machine</a></span>

    </div></td>
    <td width="73" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_machine_espresso_coffee_ingredients.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Ingredients</a></span></div></td>
    <td width="64" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_machine_selections.asp" class="style4" onMouseOver="this.className='navon'" onMouseOut="this.className='nav'">Selections</a></span></div></td>
    <td width="111" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_solution_coins_dollars_free_payment.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Payment<span class="style5">_</span>Options</a></span></div></td>
    <td width="74" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_solution_service.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Our<span class="style5">_</span>Service</a></span></div></td>
    <td width="47" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_machines_contact.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Contact</a></span></div></td>
    <td width="68" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_emergencycontact2.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Emergency</a></span></div></td>
    <td width="29" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><span class="nav"><a href="always_coffee_office_machines_jobs.asp" class="style4" onMouseOver="this.className='navon';" onMouseOut="this.className='nav';">Jobs</a></span></div></td>
    <td width="38" align="center" bgcolor="#FFFFFF" class="backnavgray"><div align="center"><a href="always_coffee_office_machine_aboutus.asp" class="style4" onMouseOver="this.className='navon'" onMouseOut="this.className='nav'">About</a></div></td>
    <td width="40" align="center" bgcolor="#FFFFFF" class="backnavgray">&nbsp;</td>
    </tr></table>

    At least can some one just right for me how the code in the past post actually work. Many thanks for any help.
    Layth
    Reply With Quote
      #4  
    Old 10-30-2004, 07:33 PM
    Charles's Avatar
    Charles Charles is offline
    JavaScript Banned
     
    Join Date: Nov 2002
    Location: Baltimore, Maryland
    Posts: 11,881
    You mkght be able to wrestle that thing into cooperating but you would do best to get rid ofthe table, use CSS for layout and presentation and go with HTML 4.01 Strict. You'll at least have to use CSS for the presentation for my method to work.
    __________________
    “The power of the Web is in its universality. Access by everyone regardless of disability is an essential aspect.”
    —Tim Berners-Lee, W3C Director and inventor of the World Wide Web
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 01:13 PM.



    Acceptable Use Policy

    Internet.com
    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.