Forum Moderators: open

Message Too Old, No Replies

IE problem using Nifty Corners solution

this is a hack for the nifty corners problem when tabbing away or using CSS

         

darkbeethoven

8:11 pm on Oct 19, 2008 (gmt 0)

10+ Year Member



I have tried all the nifty corners implementations out there and they work great, except for one thing in internet explorer: If you tab away from the page or if you use CSS to change different display attributes of the nifty corners DIV, then you get these wierd horizontal broken lines that show up all the time.
(A related post about this problem is at www.webmasterworld.com/html/3582913.htm [webmasterworld.com])

My solution to this was a hack, basically. Whenever someone using your website clicks away from the tab or away from the browser and comes back to it, you detect that with javascript and then RE-draw the nifty corners divs. The hack is two-fold: first you search through the page and *hide* the divs containing the top and bottom rounded-ness. Then you re-invoke the Rounded() functions to put new tops and bottoms on top of all the nifty corners divs.

So, for step 1, you would do the following:


var v=getElementsBySelector("b.rtop");

for(i=0;i<v.length;i++)
v[i].style.display = 'none';

v = getElementsBySelector("b.rbottom");

for(i=0;i<v.length;i++)
v[i].style.display = 'none';

The "getElementsBySelector" function is a function that already
comes with nifty corners, so it should already be there in your .js file.
Basically, it's look for all of the new horizontal <b> elements that
are a part of the style classes "bottom" and "top" and hides them.

Of course a better solution would be to just delete the goddamn things,
but I'll leave that task to someone else to do.

Step 2: re-draw the tops and bottoms fresh:

For that, of course you would just call Rounded() again on all of
your divs that you are applying nifty corners on.

Step 3: Detecting WHEN to hide the divs in step 1

For this, you want to detect when the window goes out of focus and
then comes back into focus. So, you would put the code in step 1
into a function and then call it with the following code that
goes something like this:

function onFocus(){
// call function to hide old nifty divs
// call your code to re-draw the nifty divs
};

//now tell IE to call that function when the window comes back into focus
//set this on body onload or something
window.onfocus = onFocus;

Hope that helps!

[edited by: tedster at 8:29 pm (utc) on Oct. 19, 2008]

MizzBia

10:13 pm on Oct 20, 2008 (gmt 0)

10+ Year Member



very nice of you to share!

Yaco

4:13 pm on Jan 23, 2009 (gmt 0)

10+ Year Member



Very nice the code from darkbeethoven.
But I still have the problem with IE: the code from darkbeethoven solved the problem only when I refresh the page but the first time I load it the problem is still there.
I verified also that not on all the systems this behaviour is the same: on some computers it works fine also for the first load, on other ones it works only on refresh...

So, I have found this solution:

<link rel="stylesheet" type="text/css" href="./script/niftyCorners.css">
<link rel="stylesheet" type="text/css" href="./script/niftyPrint.css" media="print">
<script type="text/javascript" src="./script/nifty.js"></script>
<script type="text/javascript">

var clockID_Nifty=0;

//Called on window onload event to draw the nifty corners the first time and to set the timeout after which the Nifty corners have to be redrawn to solve the IE problem:
function Nifty(){
Nifty_draw();
clockID_Nifty = setTimeout("Nifty_scheduled()", 1000);
}

function Nifty_scheduled(){
Nifty_Redraw();
clearTimeout(clockID_Nifty);
}

function Nifty_Redraw(){
var v=getElementsBySelector("b.rtop");
for(i=0;i<v.length;i++)
v[i].style.display = 'none';
v = getElementsBySelector("b.rbottom");
for(i=0;i<v.length;i++)
v[i].style.display = 'none';
Nifty();
};

//Draw Nifty Corners
function Nifty_draw(){
if(!NiftyCheck()) return;
//Customize the following lines to "round" your items!
Rounded(".rounded","#FFFFFF","#E5E2FF");
Rounded(".roundedLat","#E5E2FF","#DBDBDB");
Rounded(".roundedFoot","#FFFFFF","#BCB5FF");
}
</script>

<body onload="Nifty();">

And it works on IE6, IE7, FF2, FF3, Chrome on Windows XP, Vista and Windows 2000.

tedster

4:26 pm on Jan 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome to the forums, Yaco, and thanks for the additional information.