Nifty Cube is a nifty corner-rounding script for web pages written by Alessandro Fulciniti. One small drawback I discovered in it is that it requires the CSS file it uses to be in the same directory as the calling script. I wrote the following function to overcome this and make it a little easier to use:
function niftyAutoDetectCssPath()
{
var _debug = 0;
var _regex = 'niftycube.js';
var _SCRIPTS = new Array();
var nifty_path = ""; // return
// Get Script Tag Array
_SCRIPTS = document.getElementsByTagName('script');
// Loop Search for Nifty Tag
for ( i=0; i<_SCRIPTS.length; i++ )
{
var _src = _SCRIPTS[i].src
if ( _debug ) alert(_src);
if ( _src.search(_regex) != -1 )
{
if ( _debug ) alert('nifty path [' + _src + '] found!');
nifty_path = _src.substr(0, _src.lastIndexOf('/') + 1);
break;
}
}
if ( _debug ) alert('returning niftyPath [' + nifty_path + ']');
return nifty_path;
}
I tested it in my current version of Firefox and IE (6?) and it worked.
The modified package with demo is available here:
NiftyCubeAuto