SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Scroller and onMouseOver problems...

    Hi there,

    I'm working on a site that has a horizontal thumbnail scroller that when moused-over, the larger image of the thumbnail appears in a cell above.

    The problem I'm having is with this line of code:

    var menucontents='<nobr><a href="#" onMouseOver="('imgone')"><img src="images/thumb/img_01.jpg" name="imgone"></a> <a href......


    As you can see, in my onMouseOver, I have '<nobr><a href="#" onMouseOver="('imgone')">... The problem is the use of single-quotes to open the initial statement, as well as when referring to my 'imgone' object.

    Is there any way I can work around this problem so that I can have the picture loading without any problems?

    Any help would be appreciated.

    If you require any further details, please let me know.


    Thanks,
    Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  2. #2
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    just escape them

    PHP Code:
    var menucontents='<nobr><a href="#" onMouseOver="(\'imgone\')"><img src="images/thumb/img_01.jpg" name="imgone"></a> <a href...... 

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the tip... I should have thought of that, but I wasn't sure if you could do so in JavaScript.

    Now I've figured out that the quotes aren't my problem.

    I have the thumnails appearing in the lower cell, but now when I mouseOver them, the larger image does not appear.

    This is the code I'm using for to initialize my images:

    !---
    if (document.images) {
    imgoneon = new Image();
    imgoneon.src = "images/thumb/img_06.jpg";....

    function imgOn(imgName) {
    if (document.images) {
    document[imgName].src = eval(imgName + "on.src");
    document["common"].src = eval(imgName + "ad.src");
    }
    }

    This is the code that appears for my thumbnails:

    var menucontents='<nobr><a href="#" onMouseOver="(\'imgone\')"><img src="images/thumb/img_01.jpg" name="imgone"></a>....


    No luck... Any suggestions?
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <SCRIPT LANGUAGE="JavaScript">
    <!-- 
    Hide from older browsers

       
    var first_off = new Image();
       
    first_off.src "off1.gif";
       var 
    first_on = new Image();
       
    first_on.src "on1.gif";

       var 
    second_off = new Image();
       
    second_off.src "off2.gif";
       var 
    second_on = new Image();
       
    second_on.src "on2.gif";

       var 
    third_off = new Image();
       
    third_off.src "off3.gif";
       var 
    third_on = new Image();
       
    third_on.src "on3.gif";

       function 
    activate(imgName) {
         if ( eval(
    imgName "_on.complete") ) {
           
    document.images[imgName].src = eval(imgName "_on.src");
         }
       }

       function 
    deactivate(imgName) {
         if ( eval(
    imgName "_off.complete") ) {
           
    document.images[imgName].src = eval(imgName "_off.src");
         }
       }

    // End script hiding -->
    </SCRIPT> 

    preloading

  5. #5
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is that not similar to what I have as well? I don't see any difference (please keep in mind that my JS abilities are not advanced).

    Will that code also help me in the mouseOver problem I am having?


    Thanks again for all your help!


    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  6. #6
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    goto the preloading link above, that will help you but yes it does preload and also switches images

  7. #7
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew,

    Thanks for the information... I will take a look at the code used for the Preload examples page.

    Also, a quick question... Is there any difference in code when having a "normal" mouseOver (as in the example from the preload page), or when you have a mouseOver that activates the second image in a different section of the page?


    Thanks again!

    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  8. #8
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well preloading saves the image to your computers cache so it doesn't have to reload that page/picture etc again. When your mouse goes over a hyperlink it will start downloading that image, but with a preloading script it starts by saving the image to cache and then you can access that image quicker uinstead of waiting for it to download

  9. #9
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew,

    I may not have been clear in my last question.

    What I meant to say was:

    Is there a difference in having a mouseOver that activates an image in the exact same position as the original image to having a mouseOver that activates an image in a different cell/table on the page?

    Thanks,
    Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  10. #10
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is no difference at all, you just have to target that picture in stead of using this.src

  11. #11
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rather than using the this.src reference, do I need to assign an ID to the cell/table to which I want to display the picture?


    Thanks,

    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  12. #12
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes you do, but another <img src="http://i.sitepoint.com/fi/top_logo_sitepoint.gif" id="1">

  13. #13
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And in which area of the script do I put the other "ID=1" tag? Or do I just put the tag into the cell which will display the 2nd image?


    Thanks,

    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  14. #14
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Andrew,

    I wanted to thank you for your help.... Your suggestions made things a lot clearer.

    I also figured out that I was missing the imgOn command in my thumbnail hover... Which made a HUGE difference!


    Thanks again,

    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"

  15. #15
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thats good, so your problem sorted now?

  16. #16
    SitePoint Enthusiast
    Join Date
    Mar 2002
    Location
    Toronto, Canada
    Posts
    92
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah, I've managed to get it working now! It's been a frustrating week, that's for sure!

    Thanks again for everything!


    ...Frank
    ...Shakes


    "Whether you think you can, or you think you can't, you're right!"


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
  •