SitePoint Sponsor

User Tag List

Results 1 to 11 of 11
  1. #1
    SitePoint Zealot ChrisOSX's Avatar
    Join Date
    May 2002
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript rollovers--why?

    Why do some many sites implement a complete rollover script usually containing many lines of code when you can simply do the following:

    Code:
    <a href="link.html" onMouseOver="go.src='goOn.gif'" onMouseOut="go.src='go.gif'"><img name="go" src="go.gif" alt="go!" /></a>
    Is there something that I'm missing? I've tested this with IE5.x-6.0, NS4.7-7.0 on Windows (haven't checked it with my Mac yet...).

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

  3. #3
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    As Jofa has pointed out - this is normally done so you can initialize the over images as new Image objects - that way they don't get loaded with each mouseover.

    I've discovered - i think - however, that this doesn't work with background images.

    if you try saying:
    table_cell.background=preloaded_object.src
    It loads the image over tcp_ip!

    This is about as annoying as anything i've ever encountered,
    since with everything i know - i still can't find a solution.
    In this one case i'd LOVE for someone to prove me wrong ...
    ...
    ... Please!?

    I would have started a new thread for this - but i think it follows on nicely.

    (ok - you got me ... i really just don't want people to know i don't know something - Marco'll have a field day)

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  4. #4
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, the td element has no background attribute, so maybe it's a good idea trying to avoid using it

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think i can comfortably 100% disagree with that!

    http://msdn.microsoft.com/workshop/a...asp?frame=true

    If I'm not mistaken - that'd be a "background" listed in the Attributes / Properties section.

    I'm not definate that it's in the W3C definition, but since
    it's in Netscape I'm gonna guess that it is - because Netscape only do the very least they can to comply to anything .

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "This property is a Microsoft extension to HTML..."
    http://msdn.microsoft.com/library/de...ckground_2.asp

  7. #7
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Although it doesn't specifically mention manipulation via JavaScript, the article here mentions this:
    Table backgrounds involve a walk on the wild side: they are not part of the HTML 4.0 specification. They are supported by both Internet Explorer and Netscape, but in annoyingly different ways. They can be effective for certain effects, but must be used carefully if cross-browser compatibility is important to you.
    On a vaguely (but not really) related note, my search also turned up this potentially useful technique, although I can't say I've ever needed to achieve this effect:
    http://www.macromedia.com/support/dr...grnd_tiles.htm
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  8. #8
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by jofa
    "This property is a Microsoft extension to HTML..."
    I think your ... was in just the right place there

    the rest of the line continued to say:

    This property is a Microsoft extension to HTML and is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1.
    but anyway - is there a solution floating around out there?

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  9. #9
    SitePoint Wizard Goof's Avatar
    Join Date
    Feb 2001
    Location
    Pittsburgh, PA
    Posts
    1,154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by M@rco
    On a vaguely (but not really) related note, my search also turned up this potentially useful technique, although I can't say I've ever needed to achieve this effect:
    http://www.macromedia.com/support/dr...grnd_tiles.htm
    I've had to use that a lot, although maybe not quite how this page states the problem. Tables in NS4 inherit backgrounds from their parent, so if you have nested tables in NS4 and don't want your backgrounds repeated in each cell (but rather want the top tables to be transparent), you need to set background="" for the table right above the background (from there on out all tables inherit a background="" property, so the problem ceases to exist). I guess this article also says that you can set the background to a transparent gif, but why add something if you don't need it?

    [/offtopic]
    Goof
    Nathan Rutman
    A slightly offbeat creative.

  10. #10
    SitePoint Zealot ChrisOSX's Avatar
    Join Date
    May 2002
    Posts
    104
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Jofa,

    If I get your drift from the url that you sited is that the method in question that I mentioned doesn't pre-load the images? If that is true then can I just write a pre-load function that loads up all the images, but still use the method I listed as the actual rollover? Why do I need a specific changeImages() function?

  11. #11
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need a seperate function - just change the inline JS if you want!

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---


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
  •