![]() |
|
Article Options |
Restrict code in the templates to certain browsers.
by
![]() This thread will teach you how to restrict code in the templates to certain browsers. Before we begin This method is not a substitute for proper html and css. Also the way we determine the browser the client is using can easily be spoofed, it's not hard to make vBulletin think firefox is really IE for example. In other words this method should only be used when there is no other way to get the job done. The good stuff There is a function within the vBulletin source code call is_browser. With this function we can determine what type of browser the client is using, and which version of the browser the client is using. In any given template, you can use this code to display a short message to clients that use Internet Explorer:
We can also display a message based on the version number of Internet Explorer:
So why is this useful? Well lets say for some odd reason you do not support Internet Explorer 5 or lower on your site and you would like to display a short message to users visiting your site with that browser. Well we can do something like this:
This conditional would display "mysite.com only supports Internet Explorer 6.0 and higher, please upgrade your browser" in bold to any client running Internet Explorer version 5.5 or lower. Also before anyone brings this up, no it will not display the message to clients using Internet Explorer version 7. In other words the function is coded in such a way that your code is future proof. ![]() Here is a list of browsers supported by the is_browser function. The call sign is on the left (the name you should use in the function call), the browser name that call sign relates to is on the right. Supported browsers opera => Opera ie => Internet Explorer mozilla => Mozilla and Mozilla based browsers. firebird => Older versions of Firefox (below) firefox => Firefox camino => Camino konqueror => Konqueror safari => Safari webkit => webkit based applications webtv => Webtv netscape => Netscape No members have liked this post.
Last edited by Brad; 28 Jun 2006 at 21:22.. |
||||||||||||
Views: 4295
|
Comments |
#2
|
||||
|
||||
nice work brad
![]()
__________________
UNDER CONSTRUCTION: Confessionary Hack Make me a Hack of The Month author: GRPS: Groups Commune make my hacks, they'll make you famous ![]() unless it's a security concern, please do not pm/im me for support unless you're willing to pay.
No members have liked this post.
|
#3
|
||||
|
||||
Good idea
![]() No members have liked this post.
|
#4
|
|||
|
|||
Is there any way to get to the minor version using native VB code?
No members have liked this post.
|
#5
|
||||
|
||||
![]()
__________________
TechArena TechArena Community Forums Telegram - Last hope for social media engagement for vbulletin No members have liked this post.
|
#6
|
|||
|
|||
Ah, I was wondering how to do this! This helps alot!
No members have liked this post.
|
#7
|
||||
|
||||
Ah. I believe this will be very useful:
__________________
![]() ModernvB.com - vBulletin Mods & Services - ModernvB.com vBulletin 3 Mods - ModernvB.com vBulletin 4 Mods - Hire ModernvB Full-Time vB Development - If you can think it, we can build it. No members have liked this post.
|
![]() |
![]() |
||||
Article | Author | Type | Replies | Last Post |
Restrict [code] and [php] to registered members only | Dean C | vBulletin 2.x Full Releases | 24 | 21 Nov 2003 18:10 |
«
Previous Article
|
Next Article
»
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Article Options | |
|
|
New To Site? | Need Help? |
All times are GMT. The time now is 19:41.