0

I am coding a site and trying to make the mobile optimised part of the site work with a 'Find Us' button. I don't need to have anything fancy, and I now know what href to use to invoke using the 'Maps' app on Iphone, Android, Blackberry and windows phone. (thanks to: John Allan's post)

So, what I want to do now is to find either Java or another form that will let me put in the required links based upon the user-agent.

For example: I know for the Iphone I need to enter:

 <a href="http://maps.google.com/?saddr=Current%20Location&daddr= 894%20Granville%20Street%20Vancouver%20BC%20V6Z%201K3">Find Us</a> 

And for Andriod:

<a href="geo:894%20Granville%20Street%20Vancouver%20BC%20V6Z%201K3">Find Us</a>

However, I do not know how to make the code enter the right link for the right user-agent. I would like to do it inline if possible or with as little script as possible.

I have tried JSF from the post found here Check-User-Agent, but that code didn't work on my site. Currently I am just writing in HTML5.

Any help would be greatly appreciated.

4

1 回答 1

1

使用自定义标记库

您可以制作自己的自定义标签<my:geoLink city="Vancouver" ...>...</my:geoLink>,在包含标签文件的 JSP 代码中定义,使用<c:if test="request.userAgent = '...'>或这样。

于 2013-05-29T12:41:09.353 回答