|  | |  |
10-28-2004, 01:54 PM
|
#1 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| Someone want to write a script? im trying to make a script where when the person mouseovers, the image fades slowly till its slowly transpartent. so far i have:
var speed = "5";
var speed = parseInt(speed);
var dir = "1";
function fade(id, dir) {
var dir = parseInt(dir);
var temp = document.getElementById(id).filters.alpha.opacity;
var temp = parseInt(temp);
var temp = temp - speed * dir;
var temp = Math.min(100, Math.max(temp, 0));
document.getElementById(id).filters.alpha.opacity = temp;
setTimeout("blur(id, dir)", 1);
}
when they mouse over the id is the images is on onmouseover dir = 1 and on mouseoust dir = -1
im really sick of trying to try stuff, cuz i could easily do it in flash in 2 seconds, but im tryin to convert from flash to javascript. |
| |
11-03-2004, 05:58 PM
|
#2 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| i got it to work, the site isnt finished, but the link effect works. can anyone tell me what you think of it. the site is http://skatinsatan.jelloz.net |
| |
11-03-2004, 06:37 PM
|
#3 (permalink)
| | Moderator
Join Date: May 2002 Location: us.ca
Posts: 4,706
| good job .. looks good in i.e., .. but i use firefox, and it doesn't work there. =/
__________________ Mike |
| |
11-04-2004, 04:07 PM
|
#4 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| now that i think about it, it shouldnt be that hard to make it work in other browsers besides msie. its all done in simple coding. id just need to know the right parse for getting elements by their id in other broswers. anyone know? |
| |
11-05-2004, 04:52 AM
|
#5 (permalink)
| | Registered User
Join Date: Apr 2003
Posts: 30
| Has nothing to do with the id. For mozilla, I believe you need to use -moz-opacity instead of opacity. I don't know how many browsers will have a filters property for an element, though.
You'd have to check all the browsers docs.
Here's the one for Mozilla/Firefox/Netscape: http://www.mozilla.org/docs/dom/domr..._shortTOC.html
Official docs are your friend. |
| |
11-05-2004, 04:53 AM
|
#6 (permalink)
| | Registered User
Join Date: Apr 2003
Posts: 30
| Oh, and if you want this to not crash in non-DOM browsers, you better do a quick check at the beginning. Code: if (document.getElementById)
{
// code that depends on document.getElementById here
} |
| |
11-05-2004, 11:00 AM
|
#7 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| thanx, im really knew to javascript, never bothered with it before cuz i didnt want to cross broswer check, takes a lot of time in my opinion, they should just make it all the same |
| |
11-26-2004, 06:05 AM
|
#8 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| would using the following code make this more functional is different browsers? Code: var vbDOMtype = '';
if (document.getElementById) {
vbDOMtype = "std";
} else if (document.all) {
vbDOMtype = "ie4";
} else if (document.layers) {
vbDOMtype = "ns4";
}
var vBobjects = new Array();
function fetch_object(idname, forcefetch) {
if (forcefetch || typeof(vBobjects[idname]) == "undefined") {
switch (vbDOMtype) {
case "std": {
vBobjects[idname] = document.getElementById(idname);
} break;
case "ie4": {
vBobjects[idname] = document.all[idname];
} break;
case "ns4": {
vBobjects[idname] = document.layers[idname];
} break;
}
}
return vBobjects[idname];
}
Last edited by redhead; 11-26-2004 at 06:13 AM.
Reason: You need to use [ code][/ code] tags
|
| |
11-26-2004, 06:15 AM
|
#9 (permalink)
| | Super Moderator
Join Date: Jun 2002 Location: Denmark
Posts: 1,879
| Yes, but you still need a default, to catch anyone who dosn't support your three types of tests. |
| |
11-26-2004, 07:07 PM
|
#10 (permalink)
| | Regular Contributor
Join Date: Oct 2004
Posts: 238
| well i barely no a think of javascript? you mind sharing about what the default should do? |
| | | Thread Tools | | | | Display Modes | Linear Mode |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -8. The time now is 02:53 PM. |
Copyright © 2000-2008, Milano Interactive Web Hosting provided by Portal 360 Web Hosting |  | |