Go Back   Velocity Reviews > Newsgroups > HTML
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

HTML - Hey Nigel dude could it get any simpler?

 
Thread Tools Search this Thread
Old 02-07-2005, 04:10 AM   #1
Default Hey Nigel dude could it get any simpler?


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
  Reply With Quote
Old 02-07-2005, 04:37 AM   #2
Duende
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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?
  Reply With Quote
Old 02-07-2005, 05:48 AM   #3
rf
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

"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.


  Reply With Quote
Old 02-07-2005, 07:32 AM   #4
Toby Inkster
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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

  Reply With Quote
Old 02-07-2005, 12:15 PM   #5
Michael Winter
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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.
  Reply With Quote
Old 02-07-2005, 01:22 PM   #6
nice.guy.nige
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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!


  Reply With Quote
Old 02-07-2005, 02:45 PM   #7
Richard
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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?


  Reply With Quote
Old 02-07-2005, 04:05 PM   #8
nice.guy.nige
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

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

> Would you post your batcave site again then?


http://nigenet.batcave.net/thumbtastic/

or on my "proper" site at http://www.nigenet.org.uk/stuff/thumbtastic/

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!


  Reply With Quote
Old 02-07-2005, 05:42 PM   #9
Richard
 
Posts: n/a
Default Re: Hey Nigel dude could it get any simpler?

On Mon, 7 Feb 2005 16:05:40 -0000 nice.guy.nige wrote:

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


>> Would you post your batcave site again then?


> http://nigenet.batcave.net/thumbtastic/


> or on my "proper" site at http://www.nigenet.org.uk/stuff/thumbtastic/


> Cheers,
> Nige


Thanks.
Silly me. Forgot I had already saved it once.


  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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