Hey,
Due to a bug in I.E that doesn't render code properly, i'm forced to 'cloak' for I.E user agents only.
Any suggestions on best doing this?
| SitePoint Sponsor |

Hey,
Due to a bug in I.E that doesn't render code properly, i'm forced to 'cloak' for I.E user agents only.
Any suggestions on best doing this?





Which bug is this?
What do you mean by cloak?
Am I assuming your wanting to adjust the user agent of the client?

Basically if the user is using I.E, i want to show content.





Using the http_user_agent header and if required the get_browser call in PHP, you can find out which browser and version.
http://us3.php.net/function.get-browser

Cheers ears. :-)

Of course ANY useragent could be Internet Explorer since in IE that user field can be set to any value that you like (just as it can in Firefox).
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">



You could also consider doing this at the client-side rather than with PHP through the use of conditional comments.

Doing it client side is a bad idea. Very bad.



Can you elaborate on that?
@AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

It can ONLY be done client side with conditional comments. Any other way would be adding to the problem rather than fixing it.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">

Okay, basically I have to add some javascript onclick code to links, due to an I.E bug that stops them from working. So, I don't really want to be adding the onclick code for any other browsers apart from I.E, thats where the useragent comes into play. :-)
I doubt anyone who uses the site will ever have enough know-how to change the useragent themselves.
...and it's better from a seo perspective if I do not bog down the code with conditionals.
That sounds like a prime reason to do it clientside instead of serverside. Have the javascript attach the onclick handlers to the links.
But...your links won't work unless javascript is enabled in IE? Are you really sure you sure you can't fix the real problem?

It is the only solution I've manged to come up with. :-(
http://is.gd/crqY -- Try to click one of the thumbnails, in I.E.
Yeah, odd.
Have you tried removing all script and css to see if the problem remains? The html had a few errors you might wanna fix, although they seem minor.

It's the CSS that is a problem and I know exactly where it is, but I just haven't been able to find a fix for it. Sad :-(
It's the block element on the a span.
I would really seek another way around before I thought about telling IE users they better have javascript enabled if they wanna click my thumbnails. Surely you can find a way around, even if maybe your markup and css isnt as cool.
My css/html knowledge isn't great, but I thought you weren't even supposed to put block level elements inside of inline elements?

Bah, guess i'll have to recode that bit then. :-(

You can always use JScript conditionals within your JScript for anything that you want JavaScript to treat as a comment. Since IE runs JScript and all the other browsers run JavaScript a JScript conditional in the code will be treated as a JavaScript comment by all browsers except IE.
Stephen J Chapman
javascriptexample.net, Book Reviews, follow me on Twitter
HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
<input name="html5" type="text" required pattern="^$">
Bookmarks