SimplePortal
Customization => Custom Coding => Topic started by: Quinn on November 20, 2008, 05:33:35 PM
-
I have a joomla! module that displays content based on the browser version detected. Is there a way to do this in an SP block?
-
I would like to know this as well
-
Make a HTML block
<script>
//Displaying a user's browser type script
if (document.all)
var version=/MSIE \d+.\d+/
if (!document.all)
document.write("You are using "+navigator.appName+" "+navigator.userAgent)
else
document.write("You are using "+navigator.appName+" "+navigator.appVersion.match(version))
</script>
-
Make a HTML block
<script>
//Displaying a user's browser type script
if (document.all)
var version=/MSIE \d+.\d+/
if (!document.all)
document.write("You are using "+navigator.appName+" "+navigator.userAgent)
else
document.write("You are using "+navigator.appName+" "+navigator.appVersion.match(version))
</script>
yep, I knew ho to do that part but how to display content in the block based on the above generated info is still the question...
-
Or you can use SMF's built in detection. Look in Load.php under loadTheme() for the $context['browser']['is_(browser engine/name)'] stuff.
Then you can just do (for example):
if($context['browser']['is_gecko'])
displayFirefoxBlock();
else
displayOtherBlock();