Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 10-28-2004, 01:54 PM   #1 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
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.
falsepride is offline   Reply With Quote
Old 11-03-2004, 05:58 PM   #2 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
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 ishttp://skatinsatan.jelloz.net
falsepride is offline   Reply With Quote
Old 11-03-2004, 06:37 PM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,706
sde is on a distinguished road
good job .. looks good in i.e., .. but i use firefox, and it doesn't work there. =/
__________________
Mike
sde is offline   Reply With Quote
Old 11-04-2004, 04:07 PM   #4 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
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?
falsepride is offline   Reply With Quote
Old 11-05-2004, 04:52 AM   #5 (permalink)
kaeli69
Registered User
 
kaeli69's Avatar
 
Join Date: Apr 2003
Posts: 30
kaeli69 is an unknown quantity at this point
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.
kaeli69 is offline   Reply With Quote
Old 11-05-2004, 04:53 AM   #6 (permalink)
kaeli69
Registered User
 
kaeli69's Avatar
 
Join Date: Apr 2003
Posts: 30
kaeli69 is an unknown quantity at this point
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
   }
kaeli69 is offline   Reply With Quote
Old 11-05-2004, 11:00 AM   #7 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
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
falsepride is offline   Reply With Quote
Old 11-26-2004, 06:05 AM   #8 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
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
falsepride is offline   Reply With Quote
Old 11-26-2004, 06:15 AM   #9 (permalink)
redhead
Super Moderator
 
redhead's Avatar
 
Join Date: Jun 2002
Location: Denmark
Posts: 1,879
redhead is on a distinguished road
Yes, but you still need a default, to catch anyone who dosn't support your three types of tests.
__________________
Don't worry Ma'am, We're university students, We know what We're doing.
-----
If you pull the pin, Mr.Grenade would no longer be your friend.
-----
01000111 01101111 00100000 01000011 00100000 00100001
redhead is offline   Reply With Quote
Old 11-26-2004, 07:07 PM   #10 (permalink)
falsepride
Regular Contributor
 
Join Date: Oct 2004
Posts: 238
falsepride is on a distinguished road
well i barely no a think of javascript? you mind sharing about what the default should do?
falsepride is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Something wrong with the view script redhead Lounge 1 10-11-2004 01:58 PM
running a script at designated time tzarin PHP 5 05-12-2004 07:11 PM
cgi script Henry PHP 25 12-30-2002 06:54 AM
cgi not working on a new script sde PHP 3 05-20-2002 08:29 PM


All times are GMT -8. The time now is 02:53 PM.


Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0 RC8 ©2007, Crawlability, Inc.





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting