• I want to show a browser specific message. If a visitor visits from IE, then he/she will show a banner on the top of my site which will say that they should use Firefox or Chrome for the best experience (with a link to download Firefox and Chrome). How can I do that?

    I am just a simple WP user, not a web developer or coder. So providing a step-by-step deatil is much appreciated.

    My site is http://adnan.quaium.com

Viewing 8 replies - 1 through 8 (of 8 total)
  • You would need to examine the PHP $_SERVER['HTTP_USER_AGENT'] string and search it to see if it matches /.*MSIE.*/. Then on the basis of that you would have to output some HTML and add any necessary style rules for it in your style.css file.

    Also bear in mind that it’s not foolproof. User agent strings are notoriously easy to spoof.

    Are you sure this is what you want to be doing? You can have more detail if you want, but it’s not trivial (unless someone else knows better and can chip in).

    Or you could use a plugin. That’s not a recommendaton, BTW, I know nothing about it. But I could only find plugins for comments: not for visitors to the site.

    HTH

    PAE

    Thread Starter maqtanim

    (@maqtanim)

    Thanks peredur!

    Yeah… I actually want this thing! When a user visits from IE he’ll see a message to use Firefox/Chrome instead. When a visitor visits from Firefox or Chrome he will not see the message!

    OK then, you need to read up on this:

    http://php.net/manual/en/reserved.variables.server.php

    and this:

    http://php.net/manual/en/function.preg-match.php

    Use these to find out if the user agent string says it’s IE. Then use a php if() statement to conditionally output your message.

    Does that help?

    Cheers

    PAE

    Thread Starter maqtanim

    (@maqtanim)

    Thank for the links… I’ll definitely try and let you know! 🙂

    Hi maqtanim, there is a slightly easier way, from Google. It is Javascript based and a little easier to implement. It is really intended more to tell someone to upgrade, but with minor modification can be made to suit your needs.
    http://code.google.com/p/ie6-upgrade-warning/

    Thread Starter maqtanim

    (@maqtanim)

    Hi jmag, thanks for the suggestion. I’ll let you know the result (hopefully) soon.

    Meanwhile I got a plugin for the same purposes. I tried it in my localhost and it worked. With some small tweaks, it can be configared for all versions of IE.

    What do you guys think about the plugin?

    The plugin looks easy to use and is easy to implement. Visually I still think the one from Google looks nicer, but I may be biased. 🙂

    Thread Starter maqtanim

    (@maqtanim)

    Well … the Google-code one has a problem! It doesn’t let any ie6 user to proceed the website further… it forces them to upgrade anyway. But I want to let them in to my website, but with a warning to upgrade.

    I’ve got another plugin here. This is exactly what i need, except it works only for IE6 but I want to make it work for all version of IE (including IE9). So right now I am trying to do that…

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Twenty Eleven – Newbie] How can I show a browser specific notice on my site?’ is closed to new replies.