|
Web design and Programming Discuss website creation and other programming topics. |
|
Thread Tools | Search this Thread | Display Modes |
#1
|
||
|
Picture Change
Hi I need a JavaScipt code that must work! This is the following.
When someone see the image when mouse is over it, the image changes. When not changes back to an orginal. Please Thanks!
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++! |
#2
|
||
|
I'm pretty sure you can do this with CSS using back ground images. I'll read more on it, and hopefuly later I can display a lil code snippet for you to use. JS will mean less can see the rollover. (not a lot less, but still less.)
|
#3
|
||
|
Okay, seeings how I assume this is a image link let's get down to buisness
the CSS code: Code:
a { background: url("http://image.com/image/image.jpg"); /*then the rest of course*/ } a:hover { background: url("http://image.com/image/otherimage.jpg"); } Code:
<a href="index.php">Home</a> |
#4
|
||
|
I think CSS is bad. So I want it to be actionscipt.
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++! |
#5
|
||
|
Not meaning to be rude in any way, but why on earth do you think CSS is bad? Do you mean for this particular situation?
|
#6
|
||
|
No no, I like CSS. I use it only for text effects. Nevermind I wrote my own code. Thanks anyway!
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++! |
#7
|
||
|
I was about to try to dig up a JS code snippet for ya, but you wrote your own code. gj.
|
#8
|
||
|
I use the following code which requires no preloading and works like a charm.
For future reference this is the javascript you need: 1) Put this in the head Code:
<script language="JavaScript" type="text/javascript" src="PATH/FILENAME.js"></script> (Make sure you set the filename in the first code) Code:
if (document.images) { image1on = new Image(); image1on.src = "images/page1-over.gif"; image1off = new Image(); image1off.src = "images/page1.gif"; image2on = new Image(); image2on.src = "images/page2-over.gif"; image2off = new Image(); image2off.src = "images/page2.gif"; } function changeimages() { if (document.images) { for (var i=0; i<changeimages.arguments.length; i+=2) { document[changeimages.arguments[i]].src = eval(changeimages.arguments[i+1] + ".src"); } } } Code:
<a href="index.php" target="_parent" onmouseover="changeimages('image2', 'image2on')" onmouseout="changeimages('image2', 'image2off')"> Code:
name="image1" There you go |
#9
|
||
|
Oh mines much shorter!
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++! |
#10
|
||
|
Did you write it, or someone else? (@ webviper)
|
#12
|
|||
|
Quote:
|
#13
|
|||
|
Quote:
Code:
<script type="text/javascript"> function init() { if (!document.getElementById) return var imgOriginSrc; var imgTemp = new Array(); var imgarr = document.getElementsByTagName('img'); for (var i = 0; i < imgarr.length; i++) { if (imgarr[i].getAttribute('hsrc')) { imgTemp[i] = new Image(); imgTemp[i].src = imgarr[i].getAttribute('hsrc'); imgarr[i].onmouseover = function() { imgOriginSrc = this.getAttribute('src'); var imagetest=new Image() imagetest.src=this.getAttribute('hsrc') if (imagetest.complete) this.setAttribute('src',this.getAttribute('hsrc')) } imgarr[i].onmouseout = function() { var imagetest=new Image() imagetest.src=imgOriginSrc if (imagetest.complete) this.setAttribute('src',imgOriginSrc) } } } } onload=init; </script> <img src="images/menu_buttons/forums_0.gif" width="170" height="19" border="0" hsrc="images/menu_buttons/forums_1.gif">
__________________
Sorry bums, now I'm back! Now I know C++! I use Microsoft Visual C++! |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Picture: This Is Me! | Chrispy | General Chat | 27 | 08-04-2006 01:04 AM |
Picture of Yourself | Chrispy | General Chat | 1 | 07-27-2006 01:54 AM |
picture | Steve | Humor & Jokes | 7 | 08-01-2005 09:11 PM |
Hi do you put a picture under your name | Delta force man | General Chat | 6 | 08-01-2003 10:20 PM |
FUNNY PICTURE | asadznet | Humor & Jokes | 5 | 07-28-2003 05:51 AM |