mercredi 21 juin 2017

Test if user agent is either of the ones defined

I am trying to embed a javascript file into the page if the browser is either FF or Chrome. I got it working for one device but how can I do it for multiple devices?

<c:if test="${fn:contains(header['User-Agent'],'Chrome')}">
     <script>javascript file here</script>
</c:if>

I tried:

<c:if test="${fn:contains(header['User-Agent'],'FF')}">
     <script>javascript file here</script>
</c:if>

I don't want to use an if else statement as the useragents are more than two and not just FF and Chrome

Aucun commentaire:

Enregistrer un commentaire