views:

53

answers:

2

We have some HTML buttons which we format using JQuery - $('#button').button().

Works great but.. when the page first loads in IE6 you see the "unformatted" regular HTML button and then you see the JQuery formatting kick in a split second or so afterwards.

What can you do do avoid displaying the default HTML button and just display the JQuery formatted version?

+2  A: 

Put it in a div which by default it hidden CSS: #hiddenDiv {display: none;} and then after you perform all of the styling on the button using jQuery unhide the div $('#hiddenDiv').show()

Edit: To allow the button to be displayed when javascript is disabled:

<noscript>
    <style>
        #hiddenDiv
            {
            display: block!important;
            }
    </style>
</noscript>

Important: This will invalidate your HTML, as style tags are not allowed in noscript elements, and in XHTML noscript tags are not allowed in the head element.

Andrew Dunn
this is not advisable. For if javascript is disabled, users wont see the button.
Reigel
Fixed... But I feel dirty.
Andrew Dunn
+1  A: 

Try this out. In your CSS code, write

#button{
visibility: hidden
}

Put this code inside

<!--[if IE 6]>
<![endif]-->

And in your $(document).ready function, add the following.

("#button").css("visibility","visible");

Screw them if they use IE6 and disable Javascript. :P

Meher
this is not advisable. For if javascript is disabled, users wont see the button.
Reigel
simple solution, easy to implement. Yes it does mess up anyone in IE6 with JS turned off, but frankly that's just tough. To be honest, if the original problem just affects IE6 and fixes itself after page load, I'd just leave it as is. It works. Okay, so it doesn't look pretty, but you're using IE6; what do you expect??
Spudley