SitePoint Sponsor

User Tag List

Results 1 to 19 of 19
  1. #1
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Show Text for Useragent I.E

    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?

  2. #2
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Which bug is this?

    What do you mean by cloak?

    Am I assuming your wanting to adjust the user agent of the client?


  3. #3
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically if the user is using I.E, i want to show content.

  4. #4
    SitePoint Wizard gRoberts's Avatar
    Join Date
    Oct 2004
    Location
    Birtley, UK
    Posts
    2,439
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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


  5. #5
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers ears. :-)

  6. #6
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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="^$">

  7. #7
    Grumpy Minimalist
    Join Date
    Jul 2006
    Location
    Ontario, Canada
    Posts
    424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could also consider doing this at the client-side rather than with PHP through the use of conditional comments.

  8. #8
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Doing it client side is a bad idea. Very bad.

  9. #9
    Grumpy Minimalist
    Join Date
    Jul 2006
    Location
    Ontario, Canada
    Posts
    424
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you elaborate on that?

  10. #10
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by zompus View Post
    Doing it client side is a bad idea. Very bad.
    To be honest, re-coding server side logic to cope with client side issues is bad...
    @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.

  11. #11
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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="^$">

  12. #12
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  13. #13
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  14. #14
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  15. #15
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  16. #16
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  17. #17
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2008
    Posts
    5,757
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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?

  18. #18
    SitePoint Zealot zompus's Avatar
    Join Date
    May 2006
    Location
    England
    Posts
    133
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Bah, guess i'll have to recode that bit then. :-(

  19. #19
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,807
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •