Hello friends.
I am new here in this site but it looks greate.
I am creating a site and using a <div> with 900px width and 400px height. now i want to put 3 image in this div and I have 3 menu. I want a code on this menu which work with OnMousOver.
I wrote this code on my HTML
<img src="somthing.png" onmousemove="remove_pic()" id="main_pic">
and in the javascript code i have this one
function remove_pic(){
var i=1;
var opacity=0.9;
for(i=1;i<=10;i++){
element=document.getElementByid('main_pic');
setTimeout(element.style.opacity=$opacity,500);
$opacity=$opacity - 0.1;
}
}
i dont know why this does not work i know opacity just work on firefox but it does not work on fire fox too.
I appriciate any help.
}
5 replies to this topic
#1
Posted 29 December 2010 - 09:05 AM
|
|
|
#2
Posted 29 December 2010 - 10:34 AM
Different browsers handle it all differently. Your code looks fine but it's setting a style not all browsers support.
I'd recommend using a framework. They have functions like "fadeIn()" and "fadeOut" that are cross browser supported.
jQuery: The Write Less, Do More, JavaScript Library
MooTools - a compact javascript framework
I'd recommend using a framework. They have functions like "fadeIn()" and "fadeOut" that are cross browser supported.
jQuery: The Write Less, Do More, JavaScript Library
MooTools - a compact javascript framework
#3
Posted 30 December 2010 - 03:01 AM
Would this CSS Image Opacity / Transparency page help? That's what I used, when I wanted to make my own opacity-handling code.
#4
Posted 02 January 2011 - 08:15 PM
just to explain how easy it is to fadein the images, element here is a code snippet. Please add the jquery library as script source in the head of your document.
ex:
ex:
//time period of fading, 1000 msec = 1 sec
var time = 1000;
$(#'main_pic').fadeIn(time,callback);
//function executed when fading is done
function callback(){
alert('Image has been faded in');
}
Edited by gokuajmes, 02 January 2011 - 08:16 PM.
added a id indicator
#5
Posted 08 January 2011 - 10:34 PM
gokuajmes said:
just to explain how easy it is to fadein the images, element here is a code snippet. Please add the jquery library as script source in the head of your document.
ex:
ex:
//time period of fading, 1000 msec = 1 sec
var time = 1000;
$(#'main_pic').fadeIn(time,callback);
//function executed when fading is done
function callback(){
alert('Image has been faded in');
}
this:
$(#'main_pic').fadeIn(time,callback);should be
$('#main_pic').fadeIn(time,callback);
:amr:
yo homie i heard you like one-line codes so i put a one line code that evals a decrypted one line code that prints "i love one line codes"
eval(base64_decode("cHJpbnQgJ2kgbG92ZSBvbmUtbGluZSBjb2Rlcyc7"));
www.amrosama.com | the unholy methods of javascript
#6
Posted 13 January 2011 - 09:26 AM
haha u got me there amro.. thanks for the correction
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top










