Hey Nigel dude could it get any simpler?

Discussion in 'HTML' started by Richard, Feb 7, 2005.

  1. Richard

    Richard Guest

    Searching for one thing, I came across this little script found at
    javascript.internet.com.
    The sample they showed used tables.
    A row of 4 thumbs, the big picture, then another row of thumbs.
    Easily converts over to my project.
    Your basic image swap but just a tad tidier I think.


    browserName = navigator.appName;
    browserVer = parseInt(navigator.appVersion);

    ns3up = (browserName == "Netscape" && browserVer >= 3);
    ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);

    function swap(imgName) {
    if (ns3up || ie4up) {
    imgOn = ("" + imgName);
    document.thumbs.src = imgOn;
    }
    }
    Richard, Feb 7, 2005
    #1
    1. Advertising

  2. Richard

    Duende Guest

    While sitting in a puddle Richard scribbled in the mud:

    > Searching for one thing, I came across this little script found at
    > javascript.internet.com.


    The big question. Why javascript?

    --
    D?
    Duende, Feb 7, 2005
    #2
    1. Advertising

  3. Richard

    rf Guest

    "Duende" <> wrote
    > While sitting in a puddle Richard scribbled in the mud:
    >
    > > Searching for one thing, I came across this little script found at
    > > javascript.internet.com.

    >
    > The big question. Why javascript?


    Because that way it can be ensured to only work in two browsers.
    rf, Feb 7, 2005
    #3
  4. Richard

    Toby Inkster Guest

    Richard wrote:

    > Hey Nigel dude could it get any simpler?


    Much simpler...

    function swap(x) {
    document.images["thumbs"].src = x;
    }

    --
    Toby A Inkster BSc (Hons) ARCS
    Contact Me ~ http://tobyinkster.co.uk/contact
    Toby Inkster, Feb 7, 2005
    #4
  5. Richard wrote:
    > Searching for one thing, I came across this little script found at
    > javascript.internet.com.


    Don't use "The JavaScript Source". What you posted proves that it
    contains some of the worst code in existence.

    > browserName = navigator.appName;
    > browserVer = parseInt(navigator.appVersion);
    >
    > ns3up = (browserName == "Netscape" && browserVer >= 3);
    > ie4up = (browserName.indexOf("Microsoft") >= 0 && browserVer >= 4);


    Dear &deity;! Browser sniffing for a bloody image swap? Give me a break!

    > function swap(imgName) {
    > if (ns3up || ie4up) {
    > imgOn = ("" + imgName);
    > document.thumbs.src = imgOn;
    > }
    > }


    If you're going to test for support (which really is unnecessary),
    test for the images collection:

    var swap = document.images
    ? function(url) {document.images['thumbs'].src = url;}
    : function() {};

    swap('example.jpeg');

    Mike

    --
    Michael Winter
    Replace ".invalid" with ".uk" to reply by e-mail.
    Michael Winter, Feb 7, 2005
    #5
  6. While the city slept, Richard (Anonymous@127.001) feverishly typed...

    [javascript image swap]
    > Easily converts over to my project.
    > Your basic image swap but just a tad tidier I think.


    Yet it still won't work without javascript. Mine does. To be honest, it's a
    rather convoluted way of doing a basic image swap anyway.

    You already have the code to do your image swap with js. Now insert the PHP
    so it works without js and you'll be there.

    Cheers,
    Nige

    --
    Nigel Moss
    http://www.nigenet.org.uk
    Mail address not valid. , take the DOG. out!
    In the land of the blind, the one-eyed man is very, very busy!
    nice.guy.nige, Feb 7, 2005
    #6
  7. Richard

    Richard Guest

    On Mon, 7 Feb 2005 13:22:35 -0000 nice.guy.nige wrote:

    > While the city slept, Richard (Anonymous@127.001) feverishly typed...


    > [javascript image swap]
    >> Easily converts over to my project.
    >> Your basic image swap but just a tad tidier I think.


    > Yet it still won't work without javascript. Mine does. To be honest,
    > it's a
    > rather convoluted way of doing a basic image swap anyway.


    > You already have the code to do your image swap with js. Now insert the
    > PHP
    > so it works without js and you'll be there.


    > Cheers,


    Would you post your batcave site again then?
    Richard, Feb 7, 2005
    #7
  8. nice.guy.nige, Feb 7, 2005
    #8
  9. Richard

    Richard Guest

    Richard, Feb 7, 2005
    #9
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guttyguppy

    New xml dude needs help with xslt

    Guttyguppy, Sep 15, 2005, in forum: XML
    Replies:
    6
    Views:
    381
  2. Kerim Borchaev

    super. could there be a simpler super?

    Kerim Borchaev, Jan 15, 2004, in forum: Python
    Replies:
    4
    Views:
    466
    Michele Simionato
    Jan 15, 2004
  3. Merrill & Michele

    Dude and Duden

    Merrill & Michele, Dec 10, 2004, in forum: C Programming
    Replies:
    6
    Views:
    376
    Merrill & Michele
    Dec 13, 2004
  4. Marco
    Replies:
    0
    Views:
    286
    Marco
    Mar 4, 2007
  5. Pistorius

    Hyperlink dude!!

    Pistorius, Dec 23, 2009, in forum: .NET
    Replies:
    1
    Views:
    319
    Pistorius
    Dec 23, 2009
Loading...

Share This Page