473,387 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Comments on code? and one question...

Hello,

I fat fingered my newsreader while I was trying to post this before and I
don't know if it's already been posted or not. I apologise if it gets
posted more than once.

That said...

I've been meaning to write an image swapper like this for a while and
finally got around to it. I'm wondering what people think of it, comments,
suggestions, that sort of thing.

Also, the preloadimages function isn't necessary for the image swapping
functions but am I correct in assuming that the images being preloaded
will speed up the image swapping the first time the page is loaded? I
don't know if the way I'm preloading them will make them load from cache
during the image swap or not.

Let me know if you have any ideas.

<SCRIPT LANGUAGE='JavaScript'>

var myimages = new Array();

function preloadimages() {

var imagelist = new Array(
"/test/imageswap/images/test-out.gif",
"/test/imageswap/images/test-over.gif",
"/test/imageswap/images/test-click.gif",
"/test/imageswap/images/test2-out.gif",
"/test/imageswap/images/test2-over.gif",
"/test/imageswap/images/test2-click.gif"
);

for (i=0; i < imagelist.length; i++) {
myimages[i] = new Image();
myimages[i].src = imagelist[i];
}
}

preloadimages();

function imgonmouseover(currentimage) {
currentimage.src = currentimage.src.substring(0, currentimage.src.lastIndexOf('-') + 1) + 'over' + currentimage.src.substring(currentimage.src.lastIn dexOf('.'));
}

function imgonmouseout(currentimage) {
currentimage.src = currentimage.src.substring(0, currentimage.src.lastIndexOf('-') + 1) + 'out' + currentimage.src.substring(currentimage.src.lastIn dexOf('.'));
}

function imgonclick(currentimage) {
currentimage.src = currentimage.src.substring(0, currentimage.src.lastIndexOf('-') + 1) + 'click' + currentimage.src.substring(currentimage.src.lastIn dexOf('.'));
}

</SCRIPT>

<HTML>
<BODY BGCOLOR='BLACK'>
<FONT COLOR='WHITE'>
<CENTER>
<IMG BORDER='0' NAME='test' SRC='/test/imageswap/images/test-out.gif' ONMOUSEOVER='imgonmouseover(this)' ONMOUSEOUT='imgonmouseout(this)' ONCLICK='imgonclick(this)'>
<P>
<IMG BORDER='0' NAME='test2' SRC='/test/imageswap/images/test2-out.gif' ONMOUSEOVER='imgonmouseover(this)' ONMOUSEOUT='imgonmouseout(this)' ONCLICK='imgonclick(this)'>
</CENTER>
</BODY>
</HTML>
--
i.m.
All views, opinions and alleged facts expressed by this tactless moron are
protected by the constitution of the United States of America and should be
taken as good natured and friendly unless specifically stated otherwise.

Jul 20 '05 #1
1 1465
hOn Thu, 24 Jul 2003 15:04:08 -0500, "Ivan Marsh" <an*****@you.now>
wrote:
Also, the preloadimages function isn't necessary for the image swapping
functions but am I correct in assuming that the images being preloaded
will speed up the image swapping the first time the page is loaded?
Well that depends on the users cache settings, and your servers
headers, it can of course slow up loading... if you get the server
headers right, it can almost never harm.
"/test/imageswap/images/test-out.gif",
"/test/imageswap/images/test-over.gif",
"/test/imageswap/images/test-click.gif",


You could constuct these the same as you do the script - loading them
from the images in the document, so you don't need to store
information in the script.

Jim.
--
comp.lang.javascript FAQ - http://jibbering.com/faq/

Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Nigel | last post by:
I have access to a page that stores data as HTML. The code has two comments around the data that I want to get called <!-- START --> and <!-- END --> Question is, how do i read the page and grab...
5
by: Thomas Kuehne | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, I am currently reviewing some HTML parsing software. One of the source code comments reads: # Scan to end of comment.
4
by: Kieran Simkin | last post by:
Hi All, Just writing a quick function to remove HTML tags from a string (array of chars) and I'd like your comments on my code - anything you'd do differently or any mistakes etc. I'm still...
10
by: Monk | last post by:
Hi, Have a query regarding comments that extend over multiple-lines. Would like to know if the standard's view of this, so that we can create a code which doesn't run into compiler specific...
0
by: MS | last post by:
Is the schema used to validate XML Documentation Comments available to be changed by a VS.Net user? I suspect the this question is no so have a couple of requests: 1.) I use #region...
18
by: John Salerno | last post by:
I'm still tyring to figure out what "Pythonic" means, and I have a feeling the answer to my question may fall into that category. Are block comments somehow unpythonic?
5
by: Carl J. Van Arsdall | last post by:
Hey everyone, another question for the list. In particular i'm looking for comments on some of the distributed technologies supported in python. Specifically, I'm looking at XML-RPC, RPyC, CORBA,...
98
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
4
by: Joel Andres Granados | last post by:
Hi list: I have run across a situation with ConfigParser Module. It refers to the comments in the configuration filed. According to the http://docs.python.org/dev/lib/module-ConfigParser.html...
40
by: jacob navia | last post by:
Recently we had poor Mr "teapot" that was horrified at the heresy of lcc-win of accepting // comments. C is a nice language, and you can do anything with it, inclusive a program that transforms...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.