SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey folks, I've been lurking (I mean learning) for a while now, but this is one of the few times that I have posted. I am trying to find out what the best way of making my mouseovers sticky like on this site http://www.heharris.com. When you rollover a header, it changes as expected, but when you click on that image the "on" state becomes the default header for the nextsection. Any thoughts?

    Here is the code I am using for my rollovers:

    <script language="javascript">
    <!--

    if (document.images) {
    news_on = new Image();
    news_on.src = "images/nav_header_news_on.gif";
    news_off = new Image();
    news_off.src = "images/nav_header_news_off.gif";

    pr_on = new Image();
    pr_on.src = "images/nav_header_pr_on.gif";
    pr_off = new Image();
    pr_off.src = "images/nav_header_pr_off.gif";

    }

    function changeImages() {
    if (document.images) {
    for (var i=0; i<changeImages.arguments.length; i+=2) {
    document[changeImages.arguments[i]].src = eval(changeImages.arguments[i+1] + ".src");
    }
    }
    }

    // -->
    </script>

    Here is the site that I am using this on.
    http://www.oursmallgroup.com.

    Any help would be greatly appreciated.

    sincerely
    andy matthews

  2. #2
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Andy,

    The site you refer to just uses standard mouseovers. The only twist is that each of the pages linked-to by the mouseovers has a different _off image for the caption. Thus, your "news" page would display the "news" caption in the "off" state, while your "people" page would display the "people" caption in the "off" state.
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Kevin...that is not quite what I was looking for. I want to know if there is a way to display that image without having to hardcode it into the page. It appears that they are passing some osrt of variable, but getting into that sort of thing is a little past my Javascript knowledge.

    something like "when you click on this link, it tells the next page to display the 'on' image as default".

    Does dat make more sense?

    ps---------------------------
    As a side note, I want to thank you for the PHP,MySQL tutorial. I can honestly say that it will change my life. I know sounds sort of flippant, but that lesson came around at literally the PERFECT time. The "database" thing is exactly where I wanted to go in my personal development as as a designer/developer.

    A sincere thanks from this webmonkey.
    @andy


  4. #4
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Andy,

    What you describe is probably best done using PHP or some other server-side language. For example, your links could pass the name of the JavaScript variable to use for the default caption (e.g. link.html?caption=news).

    If server-side scripting is not an option for you, you could instead pass the variable in the exact same way, but grab it using JavaScript:

    Code:
    <script language="JavaScript">
    <!--
    
    // Grab the query string.
    var queryString = document.location.search.substr(1);
    
    // Get name/value pairs
    var queryVars = queryString.split("&");
    
    // Find the "caption" name/value pair:
    var pair;
    var found = false;
    for (var x=0; x<queryVars.length; x++) {
      pair = queryVars[x].split('=');
      if (pair[0] == "caption") {
        found = true;
        break;
      }
    }
    
    // Set the caption
    var caption;
    if (!found) {
      // No caption variable found -- use the default.
      caption = "defaultCaption";
    } else {
      // Get the found caption.
      caption = pair[1];
    }
    
    // ... do with the caption what you will ...
    
    //-->
    </script>
    I hope this helps more than it confuses!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  5. #5
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually Kevin...this site will be my first attempt at the deadly PHP,MySQL combo. So if you have a suggestion using the PHP method it would be perfect...

    I am actually reading your tutorial right now and I am actually getting SELECT queries right on my first try!

  6. #6
    SitePoint Author Kevin Yank's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne, Australia
    Posts
    2,571
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    After reading my article series, you should be familiar enough with PHP to know how to do this by yourself -- you'll find it's really not that complicated.

    If you still find you need help, feel free to ask!
    Kevin Yank
    CTO, sitepoint.com
    I wrote: Simply JavaScript | BYO PHP/MySQL | Tech Times | Editize
    Baby’s got back—a hard back, that is: The Ultimate CSS Reference

  7. #7
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone have any more input on this thread?
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  8. #8
    SitePoint Zealot
    Join Date
    Jun 2000
    Location
    Tulsa, OK
    Posts
    134
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just a question, did you figure it out?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •