0

对于带有下载链接的横幅,我想有条件地添加超过 1 个链接

如果用户有 Internet Explorer,它将显示 Internet Explorer 的下载链接如果用户有 Google Chrome 或 Safari,它应该显示该浏览器的链接

4

3 回答 3

3

Use this to get browser info in PHP:

$info = get_browser(null, true);

It will return an array with the browser information. You can use that information to build the proper link from the server side. See the documentation for details: http://php.net/manual/en/function.get-browser.php

于 2012-12-27T13:37:32.147 回答
2
navigator.sayswho= (function(){
    var N= navigator.appName, ua= navigator.userAgent, tem;
    var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
    if(M && (tem= ua.match(/version\/([\.\d]+)/i))!= null) M[2]= tem[1];
    M= M? [M[1], M[2]]: [N, navigator.appVersion, '-?'];

    return M;
})();

THIS IS NOT MINE! It was posted by @kennebec on this other question: jQuery browser detection?

于 2012-12-27T13:37:09.487 回答
2

If you want to detect Internet Explorer, You have to read about conditional comments. You do not need Javascript at all.

You can write:

<!--[if IE]>
<a href="ielink">some text</a>
<![endif]-->

<!--[if !IE]> -->
<a href="otherlink">some text</a>
<!-- <![endif]-->
于 2012-12-27T13:38:00.827 回答