A bug in Nifty Corners
I'm have been using the latest version of Nifty Corners (NiftyCube) in two sites for some time but one of them, my main Rails site, has been exhibiting a strange bug which I couldn't quite isolate. Sometimes the page would finish downloading but wouldn't display until either (a) I touched a key or (b) some considerable time had passed. I decided to ignore it.
But now I'm completing a third site to use Nifty Corners and I'm guessing that the client won't let me get away with ignoring it this time. I noticed that the problem was at its worst when using the Back or Forward keys as most of the pages on this third site were straight HTML with only a dash of PHP and should display almost instantly. But there was that five or ten second delay again. Maybe it was trying to download one last component of the HTML but I couldn't see why that would stop the page downloading. I decided it had to be Javascript in the window.onload function.
After some digging through Alessandro Fulciniti's very elegant Javascript, I spotted a function AddCss() where he creates a link tag to load in his CSS file niftyCorners.css. The problem was that the code assumed that the CSS file was in the current folder. I changed this to specify the folder:
function AddCss(){
niftyCss=true;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","/_css/niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}
Now I can get on with what I was supposed to be doing this afternoon. Hope this post helps someone.