cr3ative
01-28-2005, 07:31 PM
I found this script:
http://www.dynamicdrive.com/dynamicindex4/highlightgrad.htm
And loved it. But I wanted a script like this:
http://www.dynamicdrive.com/dynamicindex4/highlightgrad2.htm
Which fades back out again. Problem was, the second script didn't work in any browser except IE. So I went back to the original script (version one) and modified it to fade in and out, cross-browser.
This script has been tested on Netscape 7.1, Internet Explorer 6, Firefox 1.0, Opera 7.23 and K-Meleon 0.9. It works in all these browsers, except Opera.(Although it seems a majority of scripts dislike Opera :))
This is the new SCRIPT block (the style block stays the same, as does the IMG tag implementation:
/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* Modification by cr3ative to fade out again.
***********************************************/
var baseopacity=30
function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",20)
}
function slowlow(which2) {
cleartimer();
setTimeout(function() {fadeoutest(which2);}, 20);
}
function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}
function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}
function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
function fadeoutest(cur3){
cr3=setTimeout(function() {fadeoutest(cur3);}, 20)
if (browserdetect=="mozilla" && cur3.style.MozOpacity>0.3)
cur3.style.MozOpacity=Math.min(parseFloat(cur3.style.MozOpacity)-0.1)
else if (browserdetect=="ie" && cur3.filters.alpha.opacity>30)
cur3.filters.alpha.opacity=cur3.filters.alpha.opacity-10
if (browserdetect=="mozilla" && cur3.style.MozOpacity<=0.3)
clearTimeout(cr3);
if (browserdetect=="ie" && cur3.filters.alpha.opacity<=30)
clearTimeout(cr3);
}This should, fingers crossed, work on all modern browsers.
cr3ative
http://www.dynamicdrive.com/dynamicindex4/highlightgrad.htm
And loved it. But I wanted a script like this:
http://www.dynamicdrive.com/dynamicindex4/highlightgrad2.htm
Which fades back out again. Problem was, the second script didn't work in any browser except IE. So I went back to the original script (version one) and modified it to fade in and out, cross-browser.
This script has been tested on Netscape 7.1, Internet Explorer 6, Firefox 1.0, Opera 7.23 and K-Meleon 0.9. It works in all these browsers, except Opera.(Although it seems a majority of scripts dislike Opera :))
This is the new SCRIPT block (the style block stays the same, as does the IMG tag implementation:
/***********************************************
* Gradual Highlight image script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
* Modification by cr3ative to fade out again.
***********************************************/
var baseopacity=30
function slowhigh(which2){
imgobj=which2
browserdetect=which2.filters? "ie" : typeof which2.style.MozOpacity=="string"? "mozilla" : ""
instantset(baseopacity)
highlighting=setInterval("gradualfade(imgobj)",20)
}
function slowlow(which2) {
cleartimer();
setTimeout(function() {fadeoutest(which2);}, 20);
}
function instantset(degree){
if (browserdetect=="mozilla")
imgobj.style.MozOpacity=degree/100
else if (browserdetect=="ie")
imgobj.filters.alpha.opacity=degree
}
function cleartimer(){
if (window.highlighting) clearInterval(highlighting)
}
function gradualfade(cur2){
if (browserdetect=="mozilla" && cur2.style.MozOpacity<1)
cur2.style.MozOpacity=Math.min(parseFloat(cur2.style.MozOpacity)+0.1, 0.99)
else if (browserdetect=="ie" && cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=10
else if (window.highlighting)
clearInterval(highlighting)
}
function fadeoutest(cur3){
cr3=setTimeout(function() {fadeoutest(cur3);}, 20)
if (browserdetect=="mozilla" && cur3.style.MozOpacity>0.3)
cur3.style.MozOpacity=Math.min(parseFloat(cur3.style.MozOpacity)-0.1)
else if (browserdetect=="ie" && cur3.filters.alpha.opacity>30)
cur3.filters.alpha.opacity=cur3.filters.alpha.opacity-10
if (browserdetect=="mozilla" && cur3.style.MozOpacity<=0.3)
clearTimeout(cr3);
if (browserdetect=="ie" && cur3.filters.alpha.opacity<=30)
clearTimeout(cr3);
}This should, fingers crossed, work on all modern browsers.
cr3ative