Hey Nigel dude could it get any simpler?

R

Richard

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;
}
}
 
D

Duende

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?
 
R

rf

Duende said:
While sitting in a puddle Richard scribbled in the mud:


The big question. Why javascript?

Because that way it can be ensured to only work in two browsers.
 
M

Michael Winter

Richard said:
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
 
N

nice.guy.nige

While the city slept, Richard ([email protected]) 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
 
R

Richard

While the city slept, Richard ([email protected]) 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.

Would you post your batcave site again then?
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top